输入的数字只能是0-9
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)Dim myval As Long
'ASCII码48~57表示按键盘的0~9键,其中13为“回车”;8为“退格”
line1:
If Index = 0 Or Index = 3 Then
If KeyAscii > 57 And KeyAscii <> 13 And KeyAscii <> 8 Then 输入数字只能是0-9中的任意数字啊,这句什么意思啊
'KeyAscii = 0用于取消用户的这一次输入
KeyAscii = 0
myval = MsgBox("输入字符必须在0-9之间!", 2 + vbExclamation, "提示")
If myval = 3 Then End
If myval = 4 Then GoTo line1
If myval = 5 Then GoTo line2
line2:
text1(1).SetFocus
End If
End If
End Sub
为什么不要KeyAscii>48