输入数据的问题
我想在一个文本框中限制输入数字和英文,但下面的程序对输入“'”“/”等几个标点没有限制,请知道的高手指出错误,代码如下:Private Sub Text2_KeyPress(KeyAscii As Integer)<BR>If (KeyAscii < 48 And KeyAscii > 122) Or (KeyAscii < 65 And KeyAscii > 57) Or (KeyAscii < 97 And KeyAscii > 90) Then<BR>MsgBox "请输入正确的数据!", 48, "注意"<BR>KeyAscii = 0<BR>End If<BR>End Sub Private Sub Text2_Change()<BR> key = Asc(Right(Me.Text2.Text, 1))<BR> If (key < 48 And key > 122) Or (key < 65 And key > 57) Or (key < 97 And key > 90) Then<BR> MsgBox "请输入正确的数据!", 48, "注意"<BR> 'Me.Text2.Text = Left(Me.Text2.Text, Len(Me.Text2.Text) - 1)<BR> End If<BR>End Sub If Not ((KeyAscii < Asc("z") And KeyAscii > Asc("a")) Or (KeyAscii < Asc("Z") And KeyAscii > Asc("A")) Or (KeyAscii < Asc("9") And KeyAscii > Asc("0"))) Then<BR> <A name=63042><FONT color=#000066><B>tfyyf</B></FONT></A> 说的也行,不过绕了一个圈子,还是<A name=63073><FONT color=#990000><B>lzh741206</B></FONT></A>说的比较直观。谢谢二位!!
页:
[1]