Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to count the line in the textbox?

Posted on 2011-09-27
4
Medium Priority
?
466 Views
Last Modified: 2012-06-21
I want to count the lline in the textbox and put it to the msgbox.  I have a textbox name Text1.Text. It has multiple lines. I want to count the line.. How pls?
Text1.Text

Private Sub Command1_Click()
'text1.txt
msgbox no. of lines
End Sub
0
Comment
Question by:Whing Dela Cruz
[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
4 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 36712381
If the lines are separated with the standard vbCrLf, simply do

linecount = Ubound(Split(Text1.Text, vbCrlf)) + 1
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 36712407
That does not apply if there are multiple lines because one or more are too long and restart on another line
0
 

Author Closing Comment

by:Whing Dela Cruz
ID: 36712571
Thanks a lot...
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 36712891
I don't actually see an answer here for when you can't use vbCrLf so here goes.


Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Private Const EM_GETLINECOUNT = &HBA



    Dim LineCount As Long
    
    '-- Get the line count of Textbox
    LIneCount = SendMessage(Text1.hwnd, EM_GETLINECOUNT, 0, 0)

Open in new window


0

Featured Post

Independent Software Vendors: 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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
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…
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…
Suggested Courses

719 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