参考这个,我原来在 PY.IsHanzi还没有的时候用的正则表达式方案:
Dim City As String = e.Sender.text
If City > ""
Dim reg = new System.Text.RegularExpressions.Regex("^[\u4e00-\u9fa5]{0,}$")
If reg.Ismatch(City) = False Then
Sendkeys.SendWait("{Backspace}")
MessageBox.show("对不起,城市名必须是正确的汉字名称!")
End If
End If
其中不符合要求时,删除用的这行代码换掉您的 e.Cancel = True:
Sendkeys.SendWait("{Backspace}")