Click here to Skip to main content
15,892,737 members
Articles / Programming Languages / C#

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

Rate me:
Please Sign up or sign in to vote.
3.67/5 (3 votes)
12 Sep 2011CPOL 14.6K  
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"); }

Views

Daily Counts

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
Raised by wolves in the mean streets of Macintosh C/C++ for IBM and Motorola, moved on to Delphi and now C#. Ah, the mother's milk of Microsoft...

Comments and Discussions