Moving to last line of text in a textbox

B

BruceS

Have a text box that I use to display a log of activity after it is finished.
At the end of the processing, I set the text box to the value of a string
variable, and set focus on the text box control.

Problem: When I do this, (1) all of the text is highlighted and (2) the
text is longer than can be viewed in the control. I would like the text not
highlighted and have the cursor moved within the control to the last line.

Before I do a SendKeys ^{End} to move the cursor, I need to emulate a mouse
click. Otherwise, the cursor moves to the last control in the tab list. Did
not see anything in VBA help or KB that related to this. Is there anything
like a "SendClick" command?

If not, how can I accomplish moving to the end of the text?

Thanks,
Bruce
 
M

Marshall Barton

BruceS said:
Have a text box that I use to display a log of activity after it is finished.
At the end of the processing, I set the text box to the value of a string
variable, and set focus on the text box control.

Problem: When I do this, (1) all of the text is highlighted and (2) the
text is longer than can be viewed in the control. I would like the text not
highlighted and have the cursor moved within the control to the last line.

Before I do a SendKeys ^{End} to move the cursor, I need to emulate a mouse
click. Otherwise, the cursor moves to the last control in the tab list. Did
not see anything in VBA help or KB that related to this.


Right after the SetFocus:

Me.thetextbox.SelStart = Len(thetextbox)
 

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