How to Get the current line from the Text Box
Posted on January 5, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 'Controls - How to Get the current line from the Text Box Option Explicit 'Add a Text Box to your form and set its MultiLine property to True. 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 Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer) Dim currLine As Long currLine = SendMessageLong(Text1.hwnd, EM_LINEFROMCHAR, -1&, 0&) + 1 Debug.Print Format$(currLine, "##,###") End Sub |