rainstormmaster(rainstormmaster) 提供的是最实用的代码,若只想输入数字和字母,可以这样:
Private Sub Form_Load()
Me.KeyPreview = True
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
KeyAscii = IIf((Abs(KeyAscii - 53) <= 5 Or Abs(KeyAscii - 77) <= 13 Or Abs(KeyAscii - 110) <= 13), KeyAscii, 0)
End Sub