Question How to validate a textbox to reject letters

Old Marcus

Member
Joined
Sep 22, 2009
Messages
6
Programming Experience
Beginner
I'm doing a programming course at college, and I'm making a simple program that finds the mean of three numbers. Making the basic program was easy, but I can't work out how to validate the text boxes so that they only accept numbers. I've Googled, but I haven't been able to find anything. I have a look on the forums here but couldn't find anything either.

I'm sure this is pretty simple, but I can't work out how to go about it. Any help would be appreciated, thanks in advance.
 
Yeah, use NumericUpdDowns. ;)

Or you catch the KeyDown-Event and have a look what keys were pressed...TextChanged-Event and an regex-Replace ( [^0-9] ) might be a way.

Bobby
 
You can't use the NumericUpDown control? It's the standard textbox control for numeric input.
 
Back
Top