限制TextBox的输入字符
怎样限制TextBox只能输入字母和数字,而不能输入中文字,特殊字符和其他字符,求方法求解析求帮助
[解决办法]
Private Sub textbox1_KeyPress(sender As Object, e As KeyPressEventArgs)
If (e.KeyChar < "0"C AndAlso e.KeyChar <> 8 AndAlso e.KeyChar <> 37 AndAlso e.KeyChar <> 39 AndAlso e.KeyChar <> 46) OrElse (e.KeyChar > "9"C AndAlso e.KeyChar < "A"C) OrElse (e.KeyChar > "Z"C AndAlso e.KeyChar < "a"C) OrElse e.KeyChar > "z"C Then
e.Handled = True
End If
End Sub