Click here to Skip to main content
13,552,926 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


Posted 12 Sep 2011
Licenced CPOL

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

, 12 Sep 2011
Rate this:
Please Sign up or sign in to vote.
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"); }


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


About the Author

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...

You may also be interested in...


Comments and Discussions

GeneralReason for my vote of 4 Validation should be performed first... Pin
DrABELL13-Sep-11 3:06
memberDrABELL13-Sep-11 3:06 
GeneralYutz? Careful, your ego is showing... Pin
ChunkyStool12-Sep-11 15:27
memberChunkyStool12-Sep-11 15:27 
GeneralWhat a yutz. That's why they call it an alternative. Pin
Daaron12-Sep-11 12:19
memberDaaron12-Sep-11 12:19 
GeneralRe: thanks for your contribution, Pin
Aria Wijaya12-Sep-11 14:57
memberAria Wijaya12-Sep-11 14:57 
GeneralReason for my vote of 2 This alternative does not work for s... Pin
ChunkyStool12-Sep-11 11:44
memberChunkyStool12-Sep-11 11:44 
GeneralRe: thank you for pointing out the limitation, great stuff Pin
Aria Wijaya12-Sep-11 14:58
memberAria Wijaya12-Sep-11 14:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03-2016 | 2.8.180515.1 | Last Updated 12 Sep 2011
Article Copyright 2011 by Daaron
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid