Could someone post code for tracking rows and columns in a multiline textbox.
Printable View
Could someone post code for tracking rows and columns in a multiline textbox.
To get Line count use this:
And to get Row Number try to search for this topic on this forum (I asked the same question some time ago but I didn't copy Row Number thing)Code:Option Explicit
Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const EM_GETLINECOUNT = &HBA
Private Sub Text1_Change()
Dim lineCount As Long
On Local Error Resume Next
lineCount = SendMessageLong(Text1.hwnd, EM_GETLINECOUNT, 0&, 0&)
Label1 = Format$(lineCount, "##,###")
End Sub
HTH
Edited by QWERTY on 02-26-2000 at 12:59 PM
Your code will help, but I need to know where the position of the cursor in the textbox. I can track the position on the cursor by using Keypressed event, but it does trigger when I press the arrow keys. Also if the user moves the cursor with mouse, how do I find the new position of the cusor?
I long time ago I had achived this using my own functions, which for char position, would counnt the charactors behind the selstart position using a loop, and stop when it gets to chr(10) and chr(13).
Then for the line count I counted the chr(10) before the current selstart