Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 48 To 57
Case 97 To 100
Case Else
'If (KeyAscii < 48 Or KeyAscii > 57) Or (KeyAscii >= 97 Or KeyAscii <= 100) Then
'Else
KeyAscii = 0
MsgBox "输入了非法字符"
'End If
End Select
End Sub
已验证,运行正常