Consulting

Results 1 to 3 of 3

Thread: Userform textbox scrollbar

  1. #1
    Knowledge Base Approver
    The King of Overkill!
    VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location

    Userform textbox scrollbar

    Hi Everyone,

    I'm assuming this is a very simple thing, I've just not had to deal with it before and can't seem to find a way to fix it.

    I have a userform that has a textbox. When the form is activated, the textbox is filled with a ten-line-long string variable, with horizontal scrollbars in case the line is too long for the textbox. Most of the time it probably will be too long, and that's fine with me (wordwrap is off). However, if the 10th line is longer than the textbox itself, the scrollbars are all the way to the right, as the cursor in the textbox is blinking at the end of the scrollbar.

    I've got the textbox locked, so no one can add anything to it, is there a way to either default the blinking cursor to be at the beginning of the textbox, or even remove the cursor at all? I'm using a textbox so I can have the horizontal scroll, if theres a better way to accomplish what I need to do I'd love to hear it.

    Thanks!
    Matt

  2. #2
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Hey Matt,

    Untested as of yet, but maybe something like ...

    If TextBox1.ListCount > 0 Then TextBox1.ListIndex = 1
    ... at the end of the initialize event. (??)

  3. #3
    Knowledge Base Approver
    The King of Overkill! VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    That's a good idea, but for the textbox in the userform those aren't valid properties. I tried using textbox1.linecount, but that just causes an error in the sub

    I just tried two things and seem to have fixed the error. I changed the SelStart property to zero, and set the default property to one of the commandbuttons to true. Apparently non had default=true, so the textbox was the default (even though it has no default property). I'm not sure which of the two changes I just made fixed it, but it seems to have done the trick.

    Thanks! Without your suggestion I probably wouldn't have tried SelStart (as it's not in the properties window, only in the dropdown after entering the textboxname and the dot). I'm sure I'll be posting another Q today, having issues with this userform (after lunch though)

Posting Permissions

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