using   System.Text.RegularExpressions;   
    
Regex   digitregex   =   new   Regex(@"^[0-9]\d*[.]?\d*$");   
if   (!digitregex.IsMatch(TextBox1.Text))   
{   
TextBox1.Text="";   
MessageBox.Show("只能输入数字!","提示");   
} 


^[0-9]\d*[.]?\d*$ 是可以匹配浮点数的
^[0-9]\d*$ 是只匹配整数
上面两个都没有检测位数,自己改*

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-05
  • 2022-12-23
  • 2022-12-23
  • 2022-02-10
  • 2022-12-23
猜你喜欢
  • 2022-01-05
  • 2021-10-31
  • 2021-05-29
  • 2022-12-23
  • 2021-07-29
  • 2022-12-23
相关资源
相似解决方案