Counting Lines in RTF Boxes

Is there any API to count lines in RTF boxes?  I need to know whether an RTF box has twenty lines of text, in it, and I need that returned as either true or false. Thanks
i64XAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
halschConnect With a Mentor Commented:
RichText Box or any control that has its Text property as a string can use this function to count lines.  You can change the function to type Boolean and test "i" and set value of function to True or False.
 Hal
=====================================================
Function NumberOfLines(TextControl As String) As Long
' TextControl is the RichTextBox.Text property
i = 0
ii = 1
Do Until ii = 0
   ' Keep looking for n/l and count how many are found.
   ' InStr finds a substring in the major string starting from a
   ' defined point in the string
   ii = InStr(ii + 1, TextControl, vbNewLine)
   i = i + 1
Loop
NumberOfLines = i
End Function
0
 
mtoftCommented:
Or you could do it like this:

Dim lLines as long
lLines = SendMessage(RichTextBox1.hWnd, EM_GETLINECOUNT, 0, 0)

/Mtoft
0
All Courses

From novice to tech pro — start learning today.