using System.Text.RegularExpressions;
必须的:)
代码没错啊
正则式貌似有点问题
if (!Regex.Match(textBoxData.Text, @"^[0-9, ]{1,}$").Success)
private static Regex RegNumber = new Regex("^[0-9]+$");
///
/// 是否数字字符串
///
/// 输入字符串
///
public static bool IsNumber(string inputData)
{
Match m = RegNumber.Match(inputData);
return m.Success;
}
private void textBox1_KeyUp(object sender, KeyEventArgs e)
{
if (textBox1.Text != null && textBox1.Text != "" && textBox1.Text != "," && !IsNumber(textBox1.Text.Trim()))
{
MessageBox.Show("请输入数字,谢谢!");
textBox1.Clear();
}
}
public bool Test(TextBox textBoxData)
{
bool flag=false;
for(int i=0;i
if(textBoxData.Text[i].substring("01234567 89,")>0)
{flag=true}
}
return flag;
}