Dim pattern As String = "^[0-9-]+$" Dim txt As String= "2017-9-1" '2017年9月 Dim rgx = new System.Text.RegularExpressions.Regex(pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase) If rgx.isMatch(txt) = False Then msgbox("请输入正确的数据!") Else msgbox("正确") End If