473,513 Members | 2,559 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Counting lines of text.

Say that I have a text box that holds 5 lines of text. If the user
enters ten text lines, I want the first four lines of text displayed,
followed by a "More" hyperlink. The link will pop up another page to
display the rest of the text.

The problem is that I don't know how to count lines. I can count
characters, but this solution fails spectacularly when it encounters the
characters "<br/>" (which should be counted as a full line, of course).

Anyone have an idea how to solve the problem? Any resources I can look up?

Thanks for any help.

--Brent
Nov 19 '05 #1
3 1377
Maybe it helps if you establish what a line of text is, in your case. Is a
line something which is always ended by <br> or <p>, or does a newline count
as well (which could be checked using the Environment.NewLine property).

Kind regards,
Nikander & Margriet Bruggeman

"Brent" <""b b i g l e r "@ y a h o o ." wrote:
Say that I have a text box that holds 5 lines of text. If the user
enters ten text lines, I want the first four lines of text displayed,
followed by a "More" hyperlink. The link will pop up another page to
display the rest of the text.

The problem is that I don't know how to count lines. I can count
characters, but this solution fails spectacularly when it encounters the
characters "<br/>" (which should be counted as a full line, of course).

Anyone have an idea how to solve the problem? Any resources I can look up?

Thanks for any help.

--Brent

Nov 19 '05 #2
Good point. Hmmm ... I think for my purposes a line of text would be n
characters, or any of "<br>", "<p>", or like HTML. Mainly, I just want
to keep text fully inside a <div> with a fixed height and width. An
example of the problem is here:

http://www.thsalumni.com/Alumni.aspx?ID=2699

The information in the "Latest News" <div> extends beyond the box.

Thanks for any help.

--Brent

Nikander & Margriet Bruggeman wrote:
Maybe it helps if you establish what a line of text is, in your case. Is a
line something which is always ended by <br> or <p>, or does a newline count
as well (which could be checked using the Environment.NewLine property).

Kind regards,
Nikander & Margriet Bruggeman

"Brent" <""b b i g l e r "@ y a h o o ." wrote:

Say that I have a text box that holds 5 lines of text. If the user
enters ten text lines, I want the first four lines of text displayed,
followed by a "More" hyperlink. The link will pop up another page to
display the rest of the text.

The problem is that I don't know how to count lines. I can count
characters, but this solution fails spectacularly when it encounters the
characters "<br/>" (which should be counted as a full line, of course).

Anyone have an idea how to solve the problem? Any resources I can look up?

Thanks for any help.

--Brent

Nov 19 '05 #3
Looks like this websites uses a very practical solution. It just seems to
count the number of characters and the text stops at that point. Maybe this
is workable for you too.

Kind regards,
Nikander & Margriet Bruggeman
"Brent" <""b b i g l e r "@ y a h o o ." wrote:
Good point. Hmmm ... I think for my purposes a line of text would be n
characters, or any of "<br>", "<p>", or like HTML. Mainly, I just want
to keep text fully inside a <div> with a fixed height and width. An
example of the problem is here:

http://www.thsalumni.com/Alumni.aspx?ID=2699

The information in the "Latest News" <div> extends beyond the box.

Thanks for any help.

--Brent

Nikander & Margriet Bruggeman wrote:
Maybe it helps if you establish what a line of text is, in your case. Is a
line something which is always ended by <br> or <p>, or does a newline count
as well (which could be checked using the Environment.NewLine property).

Kind regards,
Nikander & Margriet Bruggeman

"Brent" <""b b i g l e r "@ y a h o o ." wrote:

Say that I have a text box that holds 5 lines of text. If the user
enters ten text lines, I want the first four lines of text displayed,
followed by a "More" hyperlink. The link will pop up another page to
display the rest of the text.

The problem is that I don't know how to count lines. I can count
characters, but this solution fails spectacularly when it encounters the
characters "<br/>" (which should be counted as a full line, of course).

Anyone have an idea how to solve the problem? Any resources I can look up?

Thanks for any help.

--Brent

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
7293
by: Derek Basch | last post by:
Is there a better way to count iterations that this?: pets = 0 for i in pets: pets += 1 print "pet" + "#" + pets Thanks, Derek Basch
5
2837
by: Anders K. Jacobsen [DK] | last post by:
Hi We have a rather large asp.net project with serveral utility projects (written in C#). Is there at tool out there which can give an estimate of the total amount of code lines all projects...
1
6909
by: j | last post by:
Hi, I've been trying to do line/character counts on documents that are being uploaded. As well as the "counting" I also have to remove certain sections from the file. So, firstly I was working...
5
7661
by: andy.lee23 | last post by:
hi im having trouble counting lines in a text file, i have the following code int node1, node2, i; char name; float value; ifstream fin; fin.open(OpenDialog1->FileName.c_str()); i=1;
4
2649
by: anoehre | last post by:
Hi! I have a multi-line text box in a compact framework c# application. I need a method to calculate the excact number of lines of the textbox and a method to calculate the number of used lines...
10
1493
by: cj | last post by:
I'm writing a TCP/IP server app that will have many simultaneous connections. The main thread listens for new connections and starts a thread to handle each requested connection. These are short...
7
13475
by: Mark..... | last post by:
Hi, Can someone tell me the easiest way to count the number of lines in a text file? I can write a loop to do this but it seems cumbersome.... there must be an easier way?? Thanks in...
6
16838
by: =?Utf-8?B?SGFucyAtIERpYUdyYXBoSVQgLQ==?= | last post by:
Hi! sorry for a dumb question. I have a textbox where multiline=true and I want to set the scrolbar from none to vertical when the textbox have more then f.ex. 5 lines, or reverse. How can...
7
2087
by: peraklo | last post by:
Hello, there is another problem i am facing. i have a text file which is about 15000 lines big. i have to cut the last 27 lines from that file and create a new text file that contans those 27...
0
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7160
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7537
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7099
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
3233
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1594
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.