如何在vb文本框中连续输入几个数字?

2024-11-13 12:43:24
推荐回答(3个)
回答1:

Private Sub Command1_Click()
Dim t, a() As Integer
t = Split(Text1, ",") '将text1中的内容根据逗号分割成数组
ReDim a(0 To UBound(t))
For i = 0 To UBound(t)
a(i) = Val(t(i)) '将text1中的各个数字赋值给数值数组a
Print a(i);
Next
End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode >= Asc("0") And KeyCode <= Asc("9") Then
If Text1 <> "" Then Text1 = Text1 & ","
Text1.SelStart = Len(Text1)
Else
KeyCode = 0
End If
End Sub

回答2:

if (char !=',')
那么读取
否则 i++

回答3:

split