.net introduced regular expression, see System.Text.RegularExpressions NamespaceRegular expression was introduced by java and .net, originally, java did not support it.
给你一个例子。 Regex rCode = new Regex("^\\d{6}$"); if (!rCode.IsMatch(TextBox_SecCode.Text)) { txtSecInfo.Text = "证券代码输入错误"; txtSecInfo.Visible = true; Table1.Visible = false; return ; }注:别忘了 using System.Text.RegularExpressions
Regex rCode = new Regex("^\\d{6}$");
if (!rCode.IsMatch(TextBox_SecCode.Text))
{
txtSecInfo.Text = "证券代码输入错误";
txtSecInfo.Visible = true;
Table1.Visible = false;
return ;
}注:别忘了 using System.Text.RegularExpressions
re1.ValidationExpression = "^[a-z]{1,}"
re1.ControlToValidate = TextBox1.Text
If re1.IsValid Then End If