Private Sub Text1_KeyPress(KeyAscii As Integer) If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then KeyAscii = 0 End Sub
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
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 key_press(keyascii) end sub
不好意思上边那段没写完就发出去了补上 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 keyascii=0 end if end if end sub
Private Sub Text1_KeyPress(KeyAscii As Integer) If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then KeyAscii = 0 msgbox "error!" endif End Sub
If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then KeyAscii = 0
End Sub
'允许汉字、字符、数字及汉字中的字符
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
If (KeyAscii >= 48 And KeyAscii <= 57) And KeyAscii <> 88 And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
输入数字的话不显示。
8是"退格键" 88是"删除键"
end sub
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 keyascii=0
end if
end if
end sub
If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then
KeyAscii = 0
msgbox "error!"
endif
End Sub