field validation

XsoulX

New member
Joined
Apr 10, 2009
Messages
2
Programming Experience
Beginner
Can someone tell me how to validate numeric, alphanumeric, currency, and 4-digit number in textboxes ?

Is it a good idea to use try ... catch and select ... case statement to check the data ?

Thanks.
 
I would use the Validate event to do any validation in which you'd not let the user leave the control if the data's invalid. How you would validate the data depends on what all you're doing really. But you wouldn't need a Try/Catch for it, simpler If Then would work much better.

There's also the MaskedTextBox you could use for validating things like phone numbers, social security numbers, etc.

For validating thing like email addresses and other pattern based stuff, there's Regular Expressions
 
I have planned to use if ... else statement to check for the data but then right now i have eight textboxes of different requirements. If i use if...else, i think the code will be very long so i am seeking for a shorter way of doing it. For example putting it into function or whatever.

Please help me. Thanks.
 
Back
Top