Results 1 to 6 of 6

Thread: TextBox length

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Posts
    79

    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.

  2. #2
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681
    Textbox1.MaxLength() = x, where x is the length that you want.

  3. #3
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681
    You can also set this property in the designer.

  4. #4
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Question

    Or maybe you want a masked text box?
    ~Peter


  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Posts
    79
    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.

  6. #6
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Arrow

    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.
    ~Peter


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width