'汉字
Private Sub txtName_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) Like "[!一-龥]" Then
If KeyAscii <> 8 And KeyAscii <> 9 And KeyAscii <> 13 Then
KeyAscii = 0
End If
End If
End Sub
'汉字和字母
Private Sub txtName_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) Like "[!一-龥a-zA-Z]" Then
If KeyAscii <> 8 And KeyAscii <> 9 And KeyAscii <> 13 Then
KeyAscii = 0
End If
End If
End Sub
'只能输入数字
Private Sub txtTel_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) Like "[!0-9]" Then
If KeyAscii <> 8 And KeyAscii <> 9 And KeyAscii <> 13 Then
KeyAscii = 0
End If
End If
End Sub
'字母
Private Sub txtName_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) Like "[!a-zA-Z]" Then
If KeyAscii <> 8 And KeyAscii <> 9 And KeyAscii <> 13 Then
KeyAscii = 0
End If
End If
End Sub
'汉字和字母
Private Sub txtName_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) Like "[!一-龥a-zA-Z]" Then
If KeyAscii <> 8 And KeyAscii <> 9 And KeyAscii <> 13 Then
KeyAscii = 0
End If
End If
End Sub
'只能输入数字
Private Sub txtTel_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) Like "[!0-9]" Then
If KeyAscii <> 8 And KeyAscii <> 9 And KeyAscii <> 13 Then
KeyAscii = 0
End If
End If
End Sub
'数字和汉字
Private Sub txtTel_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) Like "[!0-9一-龥]" Then
If KeyAscii <> 8 And KeyAscii <> 9 And KeyAscii <> 13 Then
KeyAscii = 0
End If
End If
End Sub
'字母和数字
Private Sub txtName_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) Like "[!0-9a-zA-Z]" Then
If KeyAscii <> 8 And KeyAscii <> 9 And KeyAscii <> 13 Then
KeyAscii = 0
End If
End If
End Sub