Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validate integer in textbox copntrol

Status
Not open for further replies.

codemech

Programmer
Feb 8, 2004
34
0
0
US
Can anyone help me with validating a textbox for an integer value. The texbox is designed to hold a contract number which is an integer value in the backend sql database. I know that a try/catch block will work and that is ok but I am looking for any other creative solutions. This is a Windows form.

Thanks,

~~ Codemech
 
A try/catch wouldn't be such a great idea, cause performance would be bad when someone is inserting a none integer.
Why not look into Double.TryParse? This function allows you to try parse a string into any number type and format and returns a bool to tell you if the conversion worked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top