By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,180 Members | 1,016 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,180 IT Pros & Developers. It's quick & easy.

word wrap

P: n/a
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
Share this Question
Share on Google+
8 Replies


P: n/a
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.be" <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

P: n/a
And how would I have te do that ?

"Curt_C [MVP]" <software_AT_darkfalz.com> schreef in bericht
news:eG**************@TK2MSFTNGP09.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.be" <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

P: n/a
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.be" <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

P: n/a
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***@TRASHaspfaq.com> schreef in bericht
news:O6**************@tk2msftngp13.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.be" <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

P: n/a
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("data")
datas = split(data, " ")
for i = 0 to ubound(datas)
if len(datas(i))>40 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.be" <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***@TRASHaspfaq.com> schreef in bericht
news:O6**************@tk2msftngp13.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.be" <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

P: n/a
> tmp = tmp & "<br>" & mid(str, i, 40)

OOPS! Change str to datas(i) here.
Jul 19 '05 #7

P: n/a
On Mon, 17 May 2004 18:20:47 GMT, "news.pandora.be" <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(WordString,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_darkfalz.com> schreef in bericht
news:eG**************@TK2MSFTNGP09.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.be" <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

P: n/a
news.pandora.be wrote on 17 mei 2004 in
microsoft.public.inetserver.asp.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 discussion thread is closed

Replies have been disabled for this discussion.