CodeItBetter Programming Another VB Programming Blog

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

Related posts:

  1. How to count number of lines in a Text box
  2. How to count number of lines in a text file
  3. How to count number of characters in RTF except crlf and spaces? (in two ways)
  4. How to count the number of textboxes in a form
  5. How to count number of files in a given directory (in two ways)
  6. How to find last 120 lines in a text file
  7. How to Get the current line from the Text Box
  8. How to Link a text box to a list box? So, as you type, it highlights any matching entries
  9. How to scan List Box for the text in TextBox
  10. How do I find the number of characters in a text box?

Filed under: Controls Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.