‘1、在窗口中有多个可操作控件时使用
Private Sub Text1_LostFocus()
If IsNumeric(Text1) = False Then MsgBox "不是数字"
End Sub
‘2、在窗口中只有一个可操作控件时使用
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If IsNumeric(Text1) = False And KeyCode = 9 Then MsgBox "不是数字"
End Sub
请采纳!谢谢!
'用text数组控件,这样写代码非常简单
Private Sub Text1_GotFocus(Index As Integer)
Print IIf(Len(Text1(Index)) > 0 And IsNumeric(Text1(Index)), "数字", "非数字")
End Sub