VB.Net Data Validation

Saint Nick

Lifer
Jan 21, 2005
17,722
6
81
In VB.Net, when a user hits a button in the form, if the value of a textbox is anything BUT an integer, I don't want it to do anything at all. So essentially, I want only integers to be accepted in the textbox.

Any help there?

TIA,
pOwder
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Isn't there a textbox control that you can put a mask on so that the user can't even enter non-integer characters?
 

Saint Nick

Lifer
Jan 21, 2005
17,722
6
81
Originally posted by: kamper
Isn't there a textbox control that you can put a mask on so that the user can't even enter non-integer characters?

I've been looking around for it, but can't find it anywhere :confused:
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Google and several discussions found with google all point here: http://www.codeproject.com/useritems/MaskedTextBox.asp

Code Project is a pretty decent place to find stuff and, although I haven't actually seen a license definition, there stuff seems to be free for just about any use (a little sketchy but, meh). Anyway, sometimes you have to tweak what you find there, but it's still a big help. I'm guessing this particular component might not handle internationalization very well but if that's important to you, you can fix it :)
 

MmmSkyscraper

Diamond Member
Jul 6, 2004
9,472
1
76
Use a MaskedTextBox. It should be available under the list of controls in your Toolbox.

Masking elements are in the Remarks section:

MSDN