Get Text Box Current Line

'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Add 1 Text Box and 1 Label to your form. Change Text Box MultiLine property to True.
'Insert this code to the module :

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
Public Const EM_LINEFROMCHAR = &HC9

'Insert the following code to your form:

Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
Dim currLine As Long
On Local Error Resume Next
currLine = SendMessageLong(Text1.hwnd, EM_LINEFROMCHAR, -1&, 0&) + 1
Label1 = Format$(currLine, "##,###")
End Sub

Go Back