How to progromatically scroll textbox

L

LGC

Hello all:

I have a textbox with a vertical scroll bar that I'm using to display a
processing log. How can I programmatically scroll the textbox so the last
entered log text shows at the bottom of the textbox?

Thanks for any suggestions.
LaVern
 
M

Marshall Barton

LGC said:
I have a textbox with a vertical scroll bar that I'm using to display a
processing log. How can I programmatically scroll the textbox so the last
entered log text shows at the bottom of the textbox?


You can not do this unless the text box has the focus. (The
scroll bar isn't even displayed until the text box gets the
focus.)

That should not be a problem as long as you're running code
since you're not providing for human interaction while the
code is running. Here's a routine I use for this kind of
thing:

Private Sub LogProgress(strMsg As String)
'must catch errors while Echo is False
On Error GoTo ErrHandler
'hide text box's text jumping around
Echo False
'add the message
Me.txtLog = Me.txtLog & strMsg & vbCrLf
'now position cursor at end of textbox
Me.txtLog.SelStart = Len(Me.txtLog)
'force a scrren update
Me.Repaint
'give repaint enough(?) time to work
DoEvents
ExitHere:
On Error Resume Next
'resume screen updates
Echo True
Exit Sub

ErrHandler:
Resume ExitHere
End Sub
 
Y

Yuan Shao

Hi LaVern,

How is the issue going on your side? Does Marsh's suggestion meet your
requirements? Let us know if you need further assistance on this issue.

Regards,

Michael Shao
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top