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
Solved

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

Posted on 1998-09-28
2
223 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 Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA saving file message display 5 72
Getting warning: You are about to delete 1 row(s) 9 52
Added a column screws up code 5 63
Set WorkSheet  not Working 9 41
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 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…
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…

839 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