有关VB禁止输入字母和特殊符号
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
End Sub
上面的只是禁止输入字母。数字和特殊符号都可以输入的
我想加多禁止输入数字和特殊符号.
应该点写?
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
End Sub
上面的只是禁止输入字母。数字和特殊符号都可以输入的
我想加多禁止输入数字和特殊符号.
应该点写?
语发错误哦!
[CODE]Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim s As String
s = "?,./:'"">~!@#$%^&*()_-+|\<>?,./:';{}[]"
If InStr(1, s, Chr(KeyAscii)) > 0 Then
KeyAscii = 0
Beep
End If
End Sub[/CODE]
烦死
不就是一些单引号.双引号吗.
自己改改不成.
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim s As String
s = "?,./:>~!@#$%^&*()_-+|\<>?,./:;{}[]"
If InStr(1, s, Chr(KeyAscii)) > 0 Then
KeyAscii = 0
Beep
End If
End Sub