不好意思上边那段没写完就发出去了补上
private sub key_press(keyascii as integer)
if keyascii<>8 then
If not (KeyAscii >= 33 And KeyAscii <= 47) Or (KeyAscii >= 58 And KeyAscii <= 65) Or KeyAscii >= 91 And KeyAscii <= 96) Or (KeyAscii >= 123 And KeyAscii <= 126) then
Private Sub Text1_KeyPress(KeyAscii As Integer)
If (KeyAscii >= 48 And KeyAscii <= 57) And KeyAscii <> 88 And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
输入数字的话不显示。
8是"退格键" 88是"删除键"
Private Sub Text1_KeyPress(KeyAscii As Integer)
'允许汉字、字符、数字及汉字中的字符
If (KeyAscii >= 33 And KeyAscii <= 47) Or _
(KeyAscii >= 58 And KeyAscii <= 65) Or _
(KeyAscii >= 91 And KeyAscii <= 96) Or _
(KeyAscii >= 123 And KeyAscii <= 126) Then MsgBox "aa"
Me.Caption = KeyAscii
End Sub