可以当数据完全输入完毕,在按钮单击事件里,执行处理程序前,加以判断:
dim i as integer
for i=1 to len(text1.text)
if (mid(text1.text,i,1)>="0" and mid(text1.text,i,1)<="9") Or _
(mid(text1.text,i,1)>="a" and mid(text1.text,i,1)<="z") Then
msgbox "输入的数据只包含数字和小写字母"
else
msgbox "输入的数据包含 [数字和小写字母] 之外的字符!"
end if
next i
根据输入字符的ASCII值判断。
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii >= 97 And KeyAscii <= 122 Then
Text1 = Text1
Else
KeyAscii = 0
End If
End Sub
楼上的不想要,那你想要什么