Results 1 to 3 of 3

Thread: Limit the Max Lengh of an Input box

  1. #1

    Thread Starter
    Hyperactive Member Matt-D's Avatar
    Join Date
    Nov 1999
    Location
    Mettmann, Germany
    Posts
    305

    Post

    Is it possible to limit the lengh of the text written in the inputbox ? (like at a text box Text1.MaxLengh = 5).

    Note: For this programm I use VB 3.0, but I have 6.0 too. (new)

    Thanx for some help, Matt
    :P

  2. #2
    Guest

    Post

    On the KeyPress Event use:

    Code:
    If Len(Text1.Text) > 5 Then
       Text1.Text = Left(Text1.Text, 5)
       Text1.SelStart = 5
    End If
    ------------------
    Boothman
    There is a war out there, and it is about who controls the information, it's all about the information.


  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    Well an InputBox doesn't have a KeyPress event. It's not elegant, but what I do is to check the length of the reply, and tell the user to re-enter it. This can be done inside a Do loop that loops until Len(strYourUserResponse) < 5.

    ------------------
    Marty
    HASTE CUISINE
    Fast French food.

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