1〉IsNumberic函数
public static bool IsNumeric(object value)
{
try
{
double i = Convert.ToDouble (value.ToString());
return true;
}
catch (FormatException)
{
return false;
}
}
2〉
//制输入数字
private void textBoxs_KeyPress(object sender, KeyPressEventArgs e)
{
string pattern = @"^[0-9]|/.$";
Regex reg = new Regex(pattern);
if ((!reg.Match(e.KeyChar.ToString()).Success)&& (e.KeyChar.ToString()!="/b"))
{
e.Handled = true;
}
else if (e.KeyChar.ToString() == "." && (sender as TextBox).Text.IndexOf(’.’) > 0)
{
e.Handled = true;
}
}