Hi all,
How do i know where the cursor position in the text at textbox?
Anyone know how to do this?

Thank you in advance

Recommended Answers

All 4 Replies

what you mean about position in text at textbox?
please give more information.

what you mean about position in text at textbox?
please give more information.

Thank your for reply sir..
I mean, when i put cursor (click) in some text i will know where the cursor is.
e.g : Daniweb.
If i put cursor between i and w then i will get cursor position is 4.

Can you help me please.

Thank you.

I mean, when i put cursor (click) in some text i will know where the cursor is.

Okay. See if this helps :

Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Text1.SelLength = 0 Then
    lCurPos = Text1.SelStart
Else
    lCurPos = Text1.SelStart + Text1.SelLength
End If
Label1.Caption = "Cursor Position " & lCurPos
End Sub
commented: It worked sir. :D +1
commented: Good +3

Okay. See if this helps :

Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Text1.SelLength = 0 Then
    lCurPos = Text1.SelStart
Else
    lCurPos = Text1.SelStart + Text1.SelLength
End If
Label1.Caption = "Cursor Position " & lCurPos
End Sub

Wow..It working sir..
Thanks for the solution.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.