|
-
Nov 28th, 2001, 08:21 AM
#1
Thread Starter
Lively Member
simple question about a textbox
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
-
Nov 28th, 2001, 08:24 AM
#2
Use the SelStart property. It will return the current cursor position.
-
Nov 28th, 2001, 08:25 AM
#3
See if this helps. Add a Label, and call it lblCurrLineNo
VB 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
-
Nov 28th, 2001, 08:27 AM
#4
Thread Starter
Lively Member
thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|