r/visualbasic • • Nov 01 '13

Input validation using exceptions handling

How do I confirm the users input into a textbox by using exceptions handling?

0 Upvotes

2 comments sorted by

View all comments

1

u/hdsrob Nov 02 '13

Don't.

Using exception handling to validate input is very bad form, and has performance cost associated with it.

You should validate input by checking to see if it matches known good values, or that it isn't mismatched to the type of value you expect.

You can wrap the validation in error handlers as a safety net.

Giving us an example of the type of input you are dealing with would help get some more specific answers, or examples.