VB中各个控件默认的text属性是什么数据类型的?string?integer?long?

如题所述

一般是string,如果不确定可以用typename去获取数据类型

温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-04-17
在窗体内加入控件text1,然后复制下面代码,运行即可(此功能不太完善,供参考):

Option Explicit

Private Sub Form_Load()
Text1.Text = " - - : : " '初始化格式
End Sub

Private Sub Text1_Change()
Select Case Text1.SelStart
Case 4, 7, 10, 13, 16 '位置控制
Text1.SelStart = Text1.SelStart + 1
End Select
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim i As Long
With Text1
If IsNumeric(Chr(KeyAscii)) = False Then KeyAscii = 0: Exit Sub '非数字退出
i = .SelStart
If i = 19 Then '防止数字输入超出范围
KeyAscii = 0
Exit Sub
End If
.Text = Left(.Text, i) & Mid(.Text, i + 2)
.SelStart = i
End With
End Sub追问

复制粘贴的垃圾

第2个回答  2018-04-17
一般是string默认的
相似回答