65.9K
CodeProject is changing. Read more.
Home

Validate numeric textbox using int.tryparse visual C#.NET

starIconstarIconstarIcon
emptyStarIcon
starIcon
emptyStarIcon

3.67/5 (3 votes)

Sep 12, 2011

CPOL
viewsIcon

15231

You could do the same thing with a regular expression:if (Regex.Replace(textBox1.Text, @"\D", "") == textBox1.Text){textBox2.Text = ("tryparse method succeed");} else { textBox2.Text=("value entered is not numeric"); }

You could do the same thing with a regular expression:
if (Regex.Replace(textBox1.Text, @"\D", "") == textBox1.Text)
{
textBox2.Text = ("tryparse method succeed");
} else { textBox2.Text=("value entered is not numeric"); }