vb 文本框数字和字母限制

只能输入数字和字母和退格键

Private Sub txtUserName_KeyPress(KeyAscii As Integer)

    If KeyAscii = 8 Then
    ElseIf KeyAscii < 48 Or (KeyAscii > 57 And KeyAscii < 64) Or (KeyAscii > 91 And KeyAscii < 96) Or KeyAscii > 122 Then KeyAscii = 0

    End If
End Sub

只能输入汉字和退格键

Private Sub txtName_KeyPress(KeyAscii As Integer)
If KeyAscii >= -20319 And KeyAscii <= -3652 Or KeyAscii = 8 Then
Else
KeyAscii = 0
End If
End Sub

只能输入数字和退格键

Private Sub txtSID_KeyPress(KeyAscii As Integer)

    If KeyAscii = 8 Then
    ElseIf KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
End If

End Sub

猜你喜欢

转载自blog.csdn.net/lclcsdnblink/article/details/81557255
VB