VBA code to move the cursor to the end of all text in a TextBox on a user Form

FaheemAhmadGul
FaheemAhmadGul used Ask the Experts™
on
I would like to move the cursor to the end of all the text in a TextBox ( named  
txtNote

Open in new window

) clicking a button on the form.
Both the TextBox and the CommandButton are on a user Form.
I am using the following code but when I click the button I find the cursor at the start of all the text and not at the end of the text.

Private Sub cmdMoveCursor_Click()
txtNote.SetFocus
txtNote.SelStart = txtNote.SelLength
End Sub

Open in new window


Thank you for your help
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2015
Distinguished Expert 2018
Commented:
Try with:

txtNote.SelStart = txtNote.Text.Length

Open in new window

Author

Commented:
Many thanks.
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
You are welcome!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial