Thursday, December 11, 2008

Check for an Integer Value-Without Exception

bool isvalid;
int number;

isvalid = int.TryParse(textBox1.Text,out number);

if (isvalid)
{
MessageBox.Show("Number");
}
if (isvalid == false)
{
MessageBox.Show("Not a number");
}

No comments: