Private Sub Text1_KeyPress(KeyAscii As Integer) Dim tMsg As String Select Case KeyAscii Case Asc(0) To Asc(9) tMsg = "输入的是数字" Case Is < 0 tMsg = "输入的是汉字或双字节字符" Case Asc("@"), Asc("$") tMsg = "输入的是“@”符号或“$”符号" Case Else tMsg = "输入的是其它" End Select MsgBox tMsg End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) '如果限制输入数字可使用下面的例程 Select Case KeyAscii Case Asc(0) To Asc(9) Case Else KeyAscii = 0 End Select End Sub
使用正则表达进行控制!!!