Solved

Counting Lines in RTF Boxes

Posted on 1998-07-17
2
151 Views
Last Modified: 2010-05-03
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
0
Comment
Question by:i64X
2 Comments
 

Accepted Solution

by:
halsch earned 20 total points
ID: 1466114
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
 
LVL 2

Expert Comment

by:mtoft
ID: 1466115
Or you could do it like this:

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

/Mtoft
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question