Solved

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

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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 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…

803 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