How to Count the Number of lines in a Text Box
Posted on January 5, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 'Controls - How to Count the Number of lines in a Text Box Option Explicit Private Declare Function SendMessageAsLong 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 = 186 Public Function GetLineCount(ByRef txt As TextBox) As Long GetLineCount = SendMessageAsLong(Text1.hWnd, EM_GETLINECOUNT, 0, 0) End Function 'How can I use this function: Sub Main() Debug.Print GetLineCount(Text1) End Sub |