Private Sub Text1_Change()
For i = 1 To Len(Text1)
S = Mid(Text1, i, 1)
If S Like "[!0-9]" And S Like "[!A-Z]" And S Like "[!a-z]" Then
Text1 = Replace(Text1, S, "")
End If
Next
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
'0-9的ASC值是48-57,A-Z大写是65-90,A-Z小写是97-122, KeyCode自动转为大写返回
If (KeyCode >= 48 And KeyCode <= 57) Or (KeyCode >= 65 And KeyCode <= 90) Then
Else
KeyCode = 0 '不给值
MsgBox ("输入无效,请重新输入!")
End If
End Sub