Page 1 of 1

Position of the cursor

Posted: 12 Nov 2008, 10:29
by bjoernlueders
How can I retrieve / set the current position of the cursor in the textbox (as with .selstart)?

Thanks,

Bjoern

Re: Position of the cursor

Posted: 12 Nov 2008, 11:47
by TiKu
Have a look at the GetSelection() method.

Re: Position of the cursor

Posted: 12 Nov 2008, 12:02
by bjoernlueders
Thank you for the fast response.

I'm stuck here. How do i identify the Position of the "selectionStart"?

Re: Position of the cursor

Posted: 12 Nov 2008, 12:07
by TiKu

Code: Select all

Dim selStart As Long

TextBox1.GetSelection selStart
' now selStart holds the cursor's position

Re: Position of the cursor

Posted: 12 Nov 2008, 12:19
by bjoernlueders
Thank you very much.

One last question: How can i set the Position afterwards to "selstart+1"? .setselection(selstart,selstart+1)?

Re: Position of the cursor

Posted: 12 Nov 2008, 12:23
by TiKu
If you just want to change the cursor's position to one character ahead, use

Code: Select all

SetSelection selStart + 1, selStart + 1
If you want to select the first character after the cursor's position, use

Code: Select all

SetSelection selStart, selStart + 1

Re: Position of the cursor

Posted: 12 Nov 2008, 12:25
by bjoernlueders
Thank you very much!
Everything is working just fine!