473,581 Members | 2,285 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

word wrap

I want to display a string in a table but when a word in the string is
longer then 40 letters it won't wrap. Does anyone know how I can fix this ?

Thanx

Wannes
Jul 19 '05 #1
8 3131
where would you expect it to wrap? if it's a single, uninterrupted, string
of characters the browser has no idea where to break it, besides it's not
right to break it most likely. You'll have to build a custom string reader
to insert a "<br>" or linebreak (if displayed in a textbox, etc).

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"news.pandora.b e" <no@no.com> wrote in message
news:ed******** **************@ phobos.telenet-ops.be...
I want to display a string in a table but when a word in the string is
longer then 40 letters it won't wrap. Does anyone know how I can fix this ?
Thanx

Wannes

Jul 19 '05 #2
And how would I have te do that ?

"Curt_C [MVP]" <software_AT_da rkfalz.com> schreef in bericht
news:eG******** ******@TK2MSFTN GP09.phx.gbl...
where would you expect it to wrap? if it's a single, uninterrupted, string
of characters the browser has no idea where to break it, besides it's not
right to break it most likely. You'll have to build a custom string reader
to insert a "<br>" or linebreak (if displayed in a textbox, etc).

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"news.pandora.b e" <no@no.com> wrote in message
news:ed******** **************@ phobos.telenet-ops.be...
I want to display a string in a table but when a word in the string is
longer then 40 letters it won't wrap. Does anyone know how I can fix
this ?

Thanx

Wannes


Jul 19 '05 #3
What kind of word is longer than 40 letters? Where would it make sense to
break up such a word? Exactly in half, after 20 characters, after 32
characters, 5 characters from the end, ...?

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/

"news.pandora.b e" <no@no.com> wrote in message
news:ed******** **************@ phobos.telenet-ops.be...
I want to display a string in a table but when a word in the string is
longer then 40 letters it won't wrap. Does anyone know how I can fix this
?

Thanx

Wannes

Jul 19 '05 #4
It's in a sort of message board so I cant realy controle what will be
displayed in the table.
I have to make shure that if someone has put in such long words my table
will still be displayed as it should.
Therefor I'm looking for an ASP-code that places an "<BR>" into my string if
there are words longer than 40 letters in it. It doesn't realy matter to me
where the words are broken as long as they are.

gr.

Wannes

"Aaron Bertrand [MVP]" <aa***@TRASHasp faq.com> schreef in bericht
news:O6******** ******@tk2msftn gp13.phx.gbl...
What kind of word is longer than 40 letters? Where would it make sense to
break up such a word? Exactly in half, after 20 characters, after 32
characters, 5 characters from the end, ...?

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/

"news.pandora.b e" <no@no.com> wrote in message
news:ed******** **************@ phobos.telenet-ops.be...
I want to display a string in a table but when a word in the string is
longer then 40 letters it won't wrap. Does anyone know how I can fix this ?

Thanx

Wannes


Jul 19 '05 #5
I would do something like this when you STORE the data (then you don't have
to do it every time you display it).

data = request.form("d ata")
datas = split(data, " ")
for i = 0 to ubound(datas)
if len(datas(i))>4 0 then
tmp = ""
for i = 1 to len(datas(i)) step 40
tmp = tmp & "<br>" & mid(str, i, 40)
next
datas(i) = tmp
end if
next
data = join(datas, " ")
' now replace single apostrophes with two, insert into db, etc.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/

"news.pandora.b e" <no@no.com> wrote in message
news:SJ******** **************@ phobos.telenet-ops.be...
It's in a sort of message board so I cant realy controle what will be
displayed in the table.
I have to make shure that if someone has put in such long words my table
will still be displayed as it should.
Therefor I'm looking for an ASP-code that places an "<BR>" into my string
if
there are words longer than 40 letters in it. It doesn't realy matter to
me
where the words are broken as long as they are.

gr.

Wannes

"Aaron Bertrand [MVP]" <aa***@TRASHasp faq.com> schreef in bericht
news:O6******** ******@tk2msftn gp13.phx.gbl...
What kind of word is longer than 40 letters? Where would it make sense
to
break up such a word? Exactly in half, after 20 characters, after 32
characters, 5 characters from the end, ...?

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/

"news.pandora.b e" <no@no.com> wrote in message
news:ed******** **************@ phobos.telenet-ops.be...
>I want to display a string in a table but when a word in the string is
> longer then 40 letters it won't wrap. Does anyone know how I can fix this > ?
>
> Thanx
>
> Wannes
>
>



Jul 19 '05 #6
> tmp = tmp & "<br>" & mid(str, i, 40)

OOPS! Change str to datas(i) here.
Jul 19 '05 #7
On Mon, 17 May 2004 18:20:47 GMT, "news.pandora.b e" <no@no.com> wrote:
And how would I have te do that ?
Something Like:

NewString = ""
StringLength = Len(WordString)
For i = 1 to (StringLength/40)
NewString = NewString & Left(WordString ,40) & "<br>" & VbCrLf
StringLength = StringLength - 40
WordString = Right(WordStrin g,StringLength)
Next
Response.Write NewString

Note, this isn't tested and it only breaks the string into 40
character lines, doesn't break on words or spaces.

But there's probably a WordWrap function floating around that
someone's already written. Hang on...

Yep. Google finds your answer:

http://www.planet-source-code.com/vb...txtCodeId=6220

Jeff

"Curt_C [MVP]" <software_AT_da rkfalz.com> schreef in bericht
news:eG******* *******@TK2MSFT NGP09.phx.gbl.. .
where would you expect it to wrap? if it's a single, uninterrupted, string
of characters the browser has no idea where to break it, besides it's not
right to break it most likely. You'll have to build a custom string reader
to insert a "<br>" or linebreak (if displayed in a textbox, etc).

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"news.pandora.b e" <no@no.com> wrote in message
news:ed******** **************@ phobos.telenet-ops.be...
> I want to display a string in a table but when a word in the string is
> longer then 40 letters it won't wrap. Does anyone know how I can fix

this
?
>
> Thanx
>
> Wannes
>
>



Jul 19 '05 #8
news.pandora.be wrote on 17 mei 2004 in
microsoft.publi c.inetserver.as p.general:
It's in a sort of message board so I cant realy controle what will be
displayed in the table.
I have to make shure that if someone has put in such long words my
table will still be displayed as it should.
Therefor I'm looking for an ASP-code that places an "<BR>" into my
string if there are words longer than 40 letters in it. It doesn't
realy matter to me where the words are broken as long as they are.


this simple j(ava)script script breaks all words
longer than 40 chars long into 40 char parts
ended by a - and a space:

t = t.replace(/(\S{40})/g,"$1- ")
=============== =======

same in vbscript [longer]:

Set regEx = New RegExp
regEx.Pattern = "(\S{40})"
regEx.Global = True
t = regEx.Replace(t , "$1- ")


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #9

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

Similar topics

11
5591
by: yawnmoth | last post by:
word wrapping normally treats some spaces as line feeds, if there hasn't been a line feed for quite a while. so while a string with eighty consecutive a's might not word wrap, a space placed squarely in the middle of that string will sorta word wrap. so why doesn't it seem to work with !'s? here's a page that demonstrates how !'s don't...
10
2312
by: Douglas G | last post by:
I've tried various ideas on this problem, but I don't see word wrapping. Can you point out what is wrong? It's a K&R exercise, and I'm still new to programming. Other pointers would be helpful too. #include "header.h" /* does the wordwrapping */ void fold(char buffer, int len) {
10
23290
by: Jeff B. | last post by:
Has anyone come across a decent algorithm for implementing word wrap features in .net printing? I have a small component that uses basic printing techniques (i.e. e.Graphics.DrawString in a PrintPage event of a PrintDocument object) to send some formatted text to the printer. However, if the lines are too long they run off the page rather...
10
72672
by: Lorenzo Thurman | last post by:
I have a table cell that I want to wrap text inside of. I've tried both hard and soft wrap, but Firefox refuses to obey. IE 6&7 handle the wrap just fine. Does anyone know how I can fix this?
0
3994
by: funeeldy | last post by:
I need to locate a particular table in a document. I cannot hardcode the table number since it could be different in every doc. I do have some header text that comes right before it consistently, though. So, I tried to find that text, and then move to the next table. Then I need to add a row to the table which already has 4 columns. I need to...
8
6935
by: gazza67 | last post by:
Hi, I want to do something that I thought would be simple but i cant seem to work it out, perhaps someone out there could help me. I want to browse for a file (it will be a word document), save the file name to a string and then at some later stage open that file with word. The operating system will be windows 2000 (dont know if that...
4
12426
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is this: can Access create the document and place it as an OLE object to the relevant table? Any help is greatly appreciated. Ricky
1
8761
by: winston.heng | last post by:
Hi, Thanks for reading this posting. I have been cracking my head on solving the infinite loop when i call the following section code. Any help or advise is greatly appreciated =D Thanks in advance. Cheers!
6
4618
by: Eric Layman | last post by:
Hi, I have fields from textareas. With a click of a button, php is able to grab these fields and by using header(), convert the output to Ms Word doc. But the outcome of the word doc doesn't wrap the text in textarea. the result is one very veyr long string of text which stretch MS word all
1
5001
by: vedika | last post by:
Hello, I have problem with word-wrapping. When width is given in pixel style="word-wrap:word-break" works well but when it is given in percentage then it is not working. <table border="1" width="20%"> <tr> <td width="10%" style="word-wrap:break-word">...
0
7862
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7789
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8144
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8301
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7894
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5670
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3820
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1400
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1132
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.