Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Feb 2003
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    UserForm textbox scroll (2000)

    I have a userform w textbox containing a large text (Lic Agreement). When I initialize the form, the cursor by default goes to the end of the text. How can I force it with vb code to move to the top of the text or force the scroll to the top?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: UserForm textbox scroll (2000)

    Use TextBox1.SelStart = 0 where TextBox1 is the name of the text box. Do this after setting the contents of the text box.

  3. #3
    3 Star Lounger
    Join Date
    Feb 2003
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: UserForm textbox scroll (2000)

    Thanks Hans. That works
    (Textbox1.SelStart=0).

    I assume the 0 is the line number??

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: UserForm textbox scroll (2000)

    SelStart is not the line number, but the position of either the blinking insertion point, or of the start of the selection, measured in characters. Its value can be between 0, i.e. at the beginning of the text, to Len(TextBox1.Text), i.e. at the very end.
    A related property is SelLength, the length of the selected text; if you see the blinking insertion point, SelLength = 0.

  5. #5
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: UserForm textbox scroll (2000)

    If you want to use the "line number" instead of char count you can use "CurLine"

    <pre>textbox1.curline = 0</pre>


    This "0" does equal the line number. This should be similar to what Hans has suggested. The curline is valid ONLY if the object has the focus. The suggestions of Hans do not require the object to have focus.

    Steve

Posting Permissions

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