-
TextBox length
Is there an easy way to limit the number of characters allowed in a textbox.
I know I can count characters but I am looking at something like format where I can specify the format which limits the number of characters. In the old days I used to do like '#######'(not in VB) and that will only allow the same number of characters.
Currently I am using Regex but this only returns an error, if i need a number it only returns an error without knowing whether the problem is the format or the length.
-
Textbox1.MaxLength() = x, where x is the length that you want.
-
You can also set this property in the designer.
-
Or maybe you want a masked text box? :confused:
-
Thanks VBCrazyCoder, crazy me I discovered that I already used this in all my textboxes except the one I had problem with. Forgot all about the maxlength.
As regards the masked textboxes that will be good, example ###.## will accept number in that form and size.
-
I found a pure .NET masked text box here, but it was kinda buggy. So i spent a couple of hours fixing it up and adding in lots of extra code to handle the issues he didn't. But it might be good enough for you.