Dim str = e.Form.Controls("密码").Text Dim reg = New System.Text.RegularExpressions.Regex("^[A-Za-z0-9]+$") If reg.Ismatch(str) = False OrElse str.Length < 6 And str.Length > 16 Then MessageBox.Show("密码必须是6-16个字母或数字组成 !","提示", MessageBoxButtons.OK,MessageBoxIcon.Question) e.Form.Controls("密码").Select() Return End If