How can I get the position of cursor in then text box?

I import the lib dzHw,and use function SendMessageToControl.

'get the position of cursor
Sub GetCurLine(txtboxname)
linechar = hdObj.SendMessageToControl(txtboxname, EM_LINEINDEX, -1, 0)
curline = hdObj.SendMessageToControl(txtboxname, EM_LINEFROMCHAR, linechar, 0)
linefirstno = hdObj.SendMessageToControl(txtboxname,EM_GETFIRSTVISIBLELINE,0,0)
Msgbox(curline & "+" & linefirstno,"Tips")
End Sub

When debug, an error ocurred."System.OverflowException"
"linechar = hdObj.SendMessageToControl(txtboxname, EM_LINEINDEX, -1, 0)"
Error Description: value -1 Uint32 too big or small??

How can I do? Tks
 
txtBoxName.SelectionStart returns the cursor position.
Are you looking for something else?

value of txtBoxName.SelectionStart is the position from first char of txtBoxName.text, I'd like to get cursor position of visible lines in the textbox .
 
Top