Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Counting Lines in RTF Boxes

Posted on 1998-07-17
2
Medium Priority
?
155 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 40 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

926 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