注册 登录
编程论坛 新人交流区

有关VB禁止输入字母和特殊符号

trylandj 发布于 2007-10-12 10:59, 971 次点击

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
End Sub

上面的只是禁止输入字母。数字和特殊符号都可以输入的
我想加多禁止输入数字和特殊符号.
应该点写?

6 回复
#2
trylandj2007-10-12 11:10
意思就是
就只能输入"文字"其他都不能输入
#3
purana2007-10-12 11:33
[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]
#4
trylandj2007-10-12 11:46

语发错误哦!

#5
purana2007-10-12 11:57

[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]

#6
purana2007-10-12 12:01

烦死
不就是一些单引号.双引号吗.
自己改改不成.
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

#7
trylandj2007-10-12 12:04
日.你是版主啊.问多几句都说烦..
而且语法错误多的是!
算了.还是跑去其他地方问好了!
1