敲了一天的代码,上上上!!!
'限制特殊字符和字母
Private Sub txtCardNumber_KeyPress(KeyAscii As Integer)
Dim cTemp As String
cTemp = "`~!@#$%^&*()-=_+[]{};:'\|<>/?.‘“”’、,。——+()《》?,~·……¥!:;【】" & """ '禁止输入特殊的字符"
If InStr(1, cTemp, Chr(KeyAscii)) <> 0 Then
KeyAscii = 0
End If
If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 8 Then
Else
KeyAscii = 0
MsgBox "只能输入数字", vbOKCancel + vbExclamation, "提示"
txtCardNumber