Solved

How do I count how many lines are in a RichTextBox?

Posted on 1998-09-28
2
216 Views
Last Modified: 2008-03-04
How do I count how many lines are in a RichTextBox?

I have VB5

Thanks!
0
Comment
Question by:eversoslightly
2 Comments
 
LVL 4

Accepted Solution

by:
mcix earned 10 total points
ID: 1437021
It will require a call to WinAPI Send Message:

Private Declare Function SendMessageAsLong Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Const EM_GETLINECOUNT = 186

Private Function GetLineCount() As Long
   GetLineCount = SendMessageAsLong(RichTextBox1.hWnd, EM_GETLINECOUNT, 0, 0)
End Function

0
 
LVL 14

Expert Comment

by:waty
ID: 1437022
MCix has responded a few seconds before me :

Private Declare Function SendMessageAsLong Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Private Function GetLineCount () as long
      '* This function will return the number of lines in the control
      Const EM_GETLINECOUNT = &H400 + 10      

      GetLineCount = SendMessage(ctrl.hwnd, EM_GETLINECOUNT, 0&,

End Function
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Is an IP address in a Range 22 72
using Access 8 52
Determine Range to Select 5 33
Access query that references subform 5 35
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now