Howto make a multipleline textbox auto scroll down

  • 12 years ago
    Hi,

    I am  doing a VB6  development, but I am facing a problem. I have a multipleline textbox(with vertical scroll enbled) in one of the form to print out the log message ... but when the message become longer and longer .. the user need to manual use the mouse to scroll down and see the last message. Can I check how we can set the textbox auto to scroll down and display the last message?

    Thank you.
  • 12 years ago

    Whenever you want to make the control to scroll down the bottom, call this sub with the handle of the control as parameter:

    Code:
    Public Sub ScrollToBottom(ByVal hWnd As Long)
       SendMessage hWnd, WMVSCROLL, SBBOTTOM, 0
    End Sub

    Of course, I have omitted the declarations of SendMessage and the other constants, but you can get those from API Viewer.

  • 12 years ago

    hi hhfei,



    Use the textbox's Scrolltocaret() property


    Code:

    TEXTBOX1.SELECT( TEXTBOX1.TEXT.LENGTH,0);
    TEXTBOX1.SCROLLTOCARET();


    Hope it helps.


  • 12 years ago

    try this


    text1.selstart = len(text1.text)

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“If Java had true garbage collection, most programs would delete themselves upon execution.” - Robert Sewell