Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Count The Number Of Lines Of A Textbox?


Hey guys I was just wondering is there a way to count the lines of text in a textbox?
Thanks.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Count The Number Of Lines In A Textbox?
Hello, does anybody know how to count the number of lines that are in a multi-line textbox? Thank you.

Count Number Of Lines In Textbox
Hi,

I saw the code of counting number of lines in textbox somewhere, but I don't really understand the main part of that code, could you give me some explanations please!

The code:
******************************************************************
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
 
lineCount = SendMessage(Text1.hwnd, EM_GETLINECOUNT, 0&, ByVal 0&)
    
*******************************************************************

1. what the "0&, ByVal 0&" means? I am always confusing about this part?

2. Why do we have to declare EM_GETLINECOUNT as a constant "&HBA", could we declare it as something else, say "&H100" or others?


many many thanks

How Can I Count The Number Of Lines In A Text File?
Im still fairly new to VB...

Stupidly simple question, I know. But I can't seem to find a easy and fast, efficient way of counting the number of lines in a text file.

I have already opened the file;

"Open cdlCommon.FileName For Input As #FileNumber"

I now need to know how many lines are in the file before I go any further...

Any ideas?!

Cheers!

Paul.

Count The Number Of Lines In A Text File
How can I count the number of lines in a text file (sequential file).

Count Number Of Lines In A Project And Insert Line Numbers
Please do not post anything if you don't want to download it.
Please.

Please test my Add-in Dll to vb which counts the number of lines, adds Line numbers to module and also removes them.
You can select which module you want to add the lines and also which modules you want to count.
Just download the dll and register.


Please post any feedback.

Thanks for testing.

PS Anyone posting REAL feedback will get the final release for free.

Count Lines And Characters In A Rich Textbox
how to show the number of lines and characters where the cursor is currently in a rich text box ?
Please help

Count The Number Of Characters In A Textbox?
how do you do it?
count how many characters you typed

Number Of Lines In Textbox
How to get number of lines in Textbox (Multiline property is True)? I remember stumbling upon a method or function that returns exactly that, but that's been ages ago and for the life of me I can't find it again in MSDN (which has one of the most useless search options in the world).

Thanks in advance.

Deckard

Count Rich Textbox Line Number....
Hi all,
currently, i working on a small project and i have some problem with my project.
i can't figure out how to get the total line number from RTB. i want to know how many line that the end-user key in.

Any suggestion will really help me a lot. Thanks

How To Count Number Of Letters As I Type It Textbox
hi all. could any one show me how i can count the number of letters as i type them in textbox. Also if i paste a sentence and press a button it shows the number of letters for me.Thanks

Note: i want to count space too.

How Do I Get VB To Count The Number Of Charcters Typed In A Textbox?
hi all,

I have a textbox...after the user enters some text in it.. I want the program to be able to find out how many charachters have been entered..

anyone help?

many thanks
Abdul

Limiting Number Of Lines In A Textbox
Is this possible???? I want to restrict the user from creating more than 7 lines of text.

Thanks

Counting The Number Of Lines In A Textbox
Hi

I want to count the number of times the enter key is pressed inside of a textbox. Any Ideas?

SOLVED : Max Number Of Lines In A Textbox ?
First of all, Sorry to all of you. I had deletted this thread to fast by accident.
MartinLiss : I have read your reply, but it was to difficult for me, i dont realy understand that piece of code. Thanks anyway.


The problem i have is the following :

I need to set the maximum number of lines for a textbox.
The textbox i have must be limmited to 5 lines/rules so that the user cant type on and on when the 5 lines ar full.

Is there realy no easy way to do this ? or is there a other textbox with this function ?

(It's just the same idea as that you can set the maxlengt, but now i need to set the maxlines)

I hope one of you can help me with this.

Maximum Number Of Lines In Textbox
I have a template in word which i want to populate automatically.
Its setup so it automatically wraps text horizontally
but it can only have a maximum of 25 lines!

From my vb program i want the user to fill in a textbox which will automaticlaly get transferred to the word document.
I've set the width of the textbox to the correct width so it matches the word template.

The only thing I can't figure out is how do I stop the textbox from accepting more characters once the 25 lines is reached???

Limiting Number Of Lines In A Textbox
Is there any api or any method for limiting the number of lines in a textbox which I won't have to count the numbers of vbCrLf characters every time the user input new text?

--
{-felipin-sioux-}
There are only 10 types of people in the world: Those who understand binary, and those who don't.


Edited by - felipin-sioux on 1/31/2004 5:51:11 PM

Limit Textbox To A Specific Number Of Lines
I set a textbox to multiline and further, I need these

1. Multiline textbox wraps the text. Instead I need to insert vbCrLf characters at the end of each line if user did not insert it pressing return manually. So I need to check each line if it has a vbCrLf at the end and place one if missing (Cause I will save the textbox content to a file and I need a delimiter for the lines to be able to pick and read a unique line from the file)

2. I need to limit the line number to 11as maximum. I can do it
counting vbCrLf if I can solve question Nr:1 though.

I can also use any other approach as basically I need to save 11 lines of textbox to a text file and be able to read any given line back.

Thanks for any help.

How To Determine Number Of Visible Lines In A Textbox?
Hi,

Can anyone tell me how to determine how many lines are visible inside a textbox ?

thanks a lot
Ruther

Set TextBox Height With No Border To The Number Of Lines Of The Text Box...?
I have a text box and I want it to grow when the text has multiple lines in it...

get it?

any ideas?

Determining The Number Of Lines In A Textbox Control *Solved*
How do I determine how many lines exist in a multi-line textbox control and then subsequently resize that textbox control so that the scrollbars are no longer needed (so that the text just all fits into the textbox).

Help appreciated.

Read Lines And Count Lines From Txt File - Thank Ye All
hello again

im back for some more help, so i hope you guys can.

ive had a quick search on the forums for this but cant find anything that helps, so heres my problem:

i have this code:
Code:
Function random2()
Dim lines As Integer
Dim current As String
lines = 0
    Open "C:files.txt" For Append As #1
    Do While Not EOF(1)
        Line Input #1, current
            lines = lines + 1
            MsgBox (current)
    Loop
    Close #1
txtFILE = lines
End Function


but that code doesnt work, it does count the lines at all, i get no msgbox's, no count, no nothing.

any help would be much appreciated.

thanks.


Primary_Slave



----------------------------------------------------------------------------------------
I'm all wrapped up in my binary blanket and I'm coding on late into the night
----------------------------------------------------------------------------------------

Edited by - Primary_Slave on 11/4/2004 9:46:42 AM

Count Lines
i have a txt file, and i whant to count all the lines, how can i do that?

Count Lines In RTB ? *Resolved*
Is it possible to count the lines in an RTB, and if it is, how is it done ??

Cheers!

Count # Of Lines In A File?
I am making a game, and info is stored in a text file. I need to know how many lines are in the text file, and it will never be a "set number".

Is there anyway to quickly count the lines? Currently, I am reading the file and increasing a counter, and then reading the file again for the data. Another option I thought about was to write the number of lines to the first line in the file (-1 of course... since you don't want that piece of info).

Any more information or suggestions would help!

Thanks

How To Count Lines Of A Word Doc In VB
Hi guys!

I want to count characters/lines of a Word Document file with VB code. Conditionally i want to exclude any type of words like bold, italic etc. If someone know any technique or anyother 3rd party component which can b used in VB for this purpose.

Waiting for response

Thanks

Asad Ijaz

" ...You may be disappointed if you fail, but you are doomed if you don’t try. "

Edited by - asadij on 9/8/2005 2:17:15 AM

Count The No. Of Lines In The Richitext Box....
I have one problem with the richitext box control. Is it possible to count the number of lines in the richitext box. and at the same time i want to know that position of the charachter on so and so line.. can any body help me???

Ravi

Count Lines Of Text In Txt File
Is there any easy way of finding out how many lines of text there are in a specific Text File ?

Count Lines Of Code In Access Db
is there a way to count all of the lines of code (sql, modules, forms, etc) in an Access db? Anything less intensive than exporting everything and count lines in text files or something...

Count Lines In A Text File
hi,
Would there happen to be a way to count how many lines there are in a text file?

THanks

Project Code Lines Count
Is there a way to count the number of code lines in a project ?

<font color=green>Do or do not
There is no try</font color=green>

How Do I Count Fields In Lines Of Data?
I have a text data file that contains tab-delimited data. What I need to do is to make a routine that goes through the data and tells me whether each line has the correct number of fields in it. Each line should have eight fields, all tab-separated.

For the life of me, I can't seem to wrap my head around what most likely is something really simple. If anyone out there can possibly help, I'd be most appreciative.

Thank you to all who reply.... looking forward to it!

Count The Lines In A Text File?
Does anybody know how to count the number of lines in a text file?

Count Numer Of Lines Of A Label
Hello to All!

Is ist possible to count the number of lines a Label has? I need this, because I want to give the label a certain height. But the caption is located in a database.

Greetings, Matt-D

Count The Lines Of Code In A Project ?
Anyone know of a utility that will tell me how many lines of code are in a project.
I could write my own, but I really couldn't be bothered.

Count Lines In Text File
What is the fastest way to determine how many lines of data are in a text file?

This text file is about 200 Mb in size, so looping through the entire file is unacceptable, since it takes about 2 minutes to do on this clunker of a machine!

Is there a better way?

How Do I Count The Lines In A RichEdit Control?
I need to see how many lines are in a RichEdit control in my program. It Delphi i could get it by saying RichEdit1.Lines.Count but don't see anything similar in VB yet. Any suggestions?

Oh, also how about the character count... Do I just do a Len(RichEdit1.text) ?

Thanks alot!

WarrenW

Read And Count Lines In A Text Box
Often, you may need to know how many lines of text there are in
a multi-line textbox. While Visual Basic makes it easy to determine
how many paragraphs the textbox contains, using code like so:

Private Sub Command1_Click()
Dim myParas As Variant
myParas = Split(Text1, vbNewLine)
MsgBox UBound(myParas) + 1
End Sub

This code, as you can see, only parses out hard carriage returns;
whereas you want to know how many lines of text the control contains.

To accomplish this task, you'll need to resort to the SendMessageAsLong()
API function. This function conforms to the following syntax:

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

To obtain the number of lines, you pass in the EM_GETLINECOUNT
constant in the wMsg parameter. Declare this constant like this:

Const EM_GETLINECOUNT = 186

Finally, to use the function, pass in the handle to the textbox
from which you want to retrieve the line count, as well as the
wMsg we mentioned earlier. Example code might look like so:

Private Sub Command2_Click()
Dim lCount As Long
lCount = SendMessageAsLong(Text1.hWnd, EM_GETLINECOUNT, 0, 0)
MsgBox lCount
End Sub

How Can I Count The Lines Of Code Of A Project?
I just want to know how many lines of code a project has, and dont want to count.
And, is there any way to put numbers to editor?
thanks

Printing Code - Lines Count
Is there an easy to find out the total number of Source Lines of Code in a project.

Thanks

Count Lines In Text File ***RESOLVED*****
Is there any way to count the number of lines in a text file.
What i am doing is reading in from a .csv file and want to incorporate a progress bar.
In order to calc percentage i need to have the total count of lines.
This is the flow i have

Code:
Set ts = fso.OpenTextFile(cdlCSV.Filename)

Do While Not ts.AtEndOfStream
str = ts.ReadLine
GetSubStrings (str) 'parse out information
Loop


Thanks guys

How To Count Lines Per Page In Crystal Report 7.0
Dear Sir/Madam,

I am using crystal report 7.0. I want to calculate no.of lines per page. Some of these lines may be blank. I want to have a formula which will increment line counter by 1 as soon as it prints one line on page.

How do I Proceed ?

Is it possible in crystal report ?

Can I get the source code for it ?

Please Help me out.

Thanks in advance.

How To Count Visual Lines In A Word Document??
I am trying to count the number of visual lines, or the number of lines that have visible characters on it in a word document. I can easily get the total number of lines in the document but am having trouble getting only the visual ones. Here is what I have so far.

Code: Public Function CountEmptyLines(ByVal doc As Word.Document) As Long
        Dim emptycount As Long = 0
        Return emptycount
    End Function

    Public Function VisualLines() As Long
        Dim linecount As Long = doc.ComputeStatistics(Word.WdStatistic.wdStatisticLines, True)
        Dim blanklines As Long = CountEmptyLines(doc)
        Return linecount - blanklines
    End Function

I am pretty much figuring that to do this I need to take the total line count and subtract the lines that have no visible characters. My problem is that I have no idea as to how to calculate the empty lines. If anyone has any brilliant ideas I would appreciate them.

Thanks.

How To Count Lines In A Text Box (RESOLVED Thanks Joacim. You're A Guru)
I'm feeding several long strings into a text box and they wrap just fine. I now need to know how many lines in the box the strings take up, irrespective of the width of the box, or the size of the font.

(RESOLVED)Count Lines Between Two Points In Text File?
Is there a way to count the number of lines between two points within a text file?

Example

Title1
Line1
Line2
Line3
Line4
Line5
Blank Line
Title5

Count Number
Hello, I do not understand how to count number ?

example:
if click Command1, will print Time text to Text1, but if need add Count, how to add it ?


1, PM 01:59:31
2, PM 01:59:31
3, PM 01:59:32
4, PM 01:59:36
5, PM 01:59:37
...etc...


Code:
Private Sub Command1_Click()

Text1.Text = Text1.Text & Time & vbCrLf
Text1.SelStart = Len(Text1.Text)

End Sub


can suggest me?
many thanks!

Count The Row Number
Hi,

I have a speedsheet in Excel. I need to write a VBA(macro) to count the row number for a column, for example colum A1

how to do this? would you privide some example code?

Thanks

Jack

Count Number Of Record Of An MDB
HOW,
I have an .mdb with a table TOTALE i would want to count the numer of the record and put the result in A2 of a sheet
this is the path
e:prova.mdb

Copyright © 2005-08 www.BigResource.com, All rights reserved