Results 1 to 6 of 6
  1. #1
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Limiting textbox input (VBA Office 2000)

    I'm using a multiline textbox for input on a userform. I'm wanting to limit line length to 58 characters and maximum number of lines to 7. I'm hoping to achieve this without the need to slow things up by continually monitoring user input, nor to do an "after the event" analysis. It's probably an "impossible" ask, but if there's anywhere to achieve the impossible, it's probably here in Woody's Lounge. <img src=/S/grin.gif border=0 alt=grin width=15 height=15> Any clever tricks to enable this?

    Alan

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Limiting textbox input (VBA Office 2000)

    Alan,
    Not exactly a work of art, but the attached userform1.frm may give you an idea.
    (rename userform1.frm.txt to username1.frm)

    You can easily limit the line count of a text box; the line length I approximated by testing
    the width property.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Limiting textbox input (VBA Office 2000)

    Thanks Kevin. I can't import the renamed file into an XL project though. I get an unspecified system error, then an "Out of Memory" message. The error log says:
    Line 8: Property OleObjectBlob in UserForm1 had an invalid file reference.

    And line 8 is:
    OleObjectBlob = "UserForm1.frx":0000

    I have no idea of what any of this means; at a guess, there should be a .frx file to go with it ??? But the actual VB code is easy enough to comprendi. I'll have a play <img src=/S/grin.gif border=0 alt=grin width=15 height=15>. I presume you set the textbox to autosize so that its width could expand up to the value of 80 points?

    Edited - I can't seem to get this to work for a multiline textbox. Apparently with multiline and autosize set to true, the textbox resorts to a vertical display of text (one character width).

    cheers

    Alan

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Limiting textbox input (VBA Office 2000)

    Hi Kevin, you probably need to zip up the FRM and FRX files together for this. (FRX isn't text, or isn't very nice-looking text...)

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Limiting textbox input (VBA Office 2000)

    <P ID="edit" class=small>(Edited by jscher2000 on 10-Dec-03 22:56. See Note.)</P>On your textbox, try these properties:

    Font = Courier New, 8 point
    Height = 86
    Multiline = True
    Width = 318

    In my test, this fits 7 lines of 58 characters. Because more can be entered, you still will need Kevin's code or a variation thereon to stop input after it is full.

    P.S. Set AutoSize to False.

  6. #6
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Limiting textbox input (VBA Office 2000)

    Thanks Jefferson and Kevin. That works well.

    Alan

Posting Permissions

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