Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Counting Lines in RTF Boxes

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Suggested Courses

670 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