how do i know my position inside a textbox?
for example, if i have a textbox with multiline, and alot of text inside. the cursor is somewhere in the middle.
how can i count - or get somehow the position of the cursor
Printable View
how do i know my position inside a textbox?
for example, if i have a textbox with multiline, and alot of text inside. the cursor is somewhere in the middle.
how can i count - or get somehow the position of the cursor
Use the SelStart property. It will return the current cursor position.
See if this helps. Add a Label, and call it lblCurrLineNoVB Code:
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Copyright ©1996-2001 VBnet, Randy Birch, All Rights Reserved. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' You are free to use this code within your own applications, ' but you are expressly forbidden from selling or otherwise ' distributing this source code without prior written consent. ' This includes both posting free demo projects made from this ' code as well as reproducing the code in text or html format. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Const EM_LINEFROMCHAR = &HC9 Private Sub Text1_Change() 'get the line the cursor is currently on Dim currLine As Long On Local Error Resume Next currLine = SendMessage(Text1.hwnd, EM_LINEFROMCHAR, -1&, ByVal 0&) + 1 lblCurrLineNo = Format$(currLine, "##,###") End Sub
thanks
:p