Solved

Counting Lines in RTF Boxes

Posted on 1998-07-17
2
152 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

738 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