Solved

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

Posted on 1998-09-28
2
224 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

679 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