How do I restrict input to a 4 digit integer in a Windows TextBox in VB.NET?
Posted on 2012-04-04
I'm using a textbox as a year input control, and I want to restrict the input to 4 numeric digits. That is it shouldn't be possible to even key in other characters than 0-9. The input is easy to validate afterwards and provide feedback, but I like the restriction method better.
I have tried to use the MaskedTextBox that holds the functionality, but I really don't like its feel. Is it possible to tweak a MaskedTextbox to have the same feel as a standard TextBox (no prompt characters) or can I in some way implement the above mentioned restriction for a normal TextBox?