Dim myex = New System.Text.RegularExpressions.Regex("^[A-Za-z0-9]+$") Dim str1 = e.Sender.Text If myex.IsMatch(str1) Then Dim idx As Integer = e.sender.SelectionStart e.Sender.Text = str1.ToUpper e.Sender.Error = "" e.Sender.SelectionStart = idx Else e.Sender.Error = "必须为数字或字母" End If