Option Explicit
'接受和控制一个文本框
Private WithEvents myTXT As TextBox
'模块级变量用来检测输入的是否为数字
Private IsNumber As Boolean
'接受一个外部变量到myTXT中
Public Sub Attach(ByVal itTXT As TextBox)
Set myTXT = itTXT
End Sub
Private Sub myTXT_KeyUp(KeyAscii As Integer, Shift As Integer)
'检测键盘输入的是否为数字0-9和连接符,退格
If KeyAscii > 47 And KeyAscii < 58 Or KeyAscii = 8 Or KeyAscii = 45 Then
IsNumber = True
Else
IsNumber = False
Beep
'如果不是则清空文本框
myTXT = ""
End If
End Sub
问题:
用小键盘输入数字同样无效,想知道why?