Solved

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

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Microsoft Access combo box help 2 57
vb6 connector to mongodb 2 165
vbModal 12 75
how to read data from all excel sheet and copy it in in Master sheet 2 28
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…
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.
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…

752 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