473,414 Members | 1,605 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

A string has no line feeds or cariage retunrs or spaces, need to insert a vbCrLf

When users fill out my text area field, there is a chance that there
will be no line feeds or cariage returns or spaces and just one really
long word. THIS CAUSES A MAJOR PROBLEM! What I am trying to do is
force a vbCrLf if a string is long than 80 characters in a row. So if
a string is a total of 500 characters with no line feeds, spaces, or
returns, I want to force a vbCrLf every 80 characters so that is
doesn't overflow my preview text field on the next page.

Any suggestions on how the algorithm would be for this in VBscript
ASP?

Thanks,
Jason
Jul 19 '05 #1
7 3246
Gazing into my crystal ball I observed al******@msn.com (Jason) writing in
news:ce**************************@posting.google.c om:
When users fill out my text area field, there is a chance that there
will be no line feeds or cariage returns or spaces and just one really
long word. THIS CAUSES A MAJOR PROBLEM! What I am trying to do is
force a vbCrLf if a string is long than 80 characters in a row. So if
a string is a total of 500 characters with no line feeds, spaces, or
returns, I want to force a vbCrLf every 80 characters so that is
doesn't overflow my preview text field on the next page.

Any suggestions on how the algorithm would be for this in VBscript
ASP?

Thanks,
Jason


How about:
for each word in split(request.form("test")," ")
if len(trim(word)) > 5 then
test = test & left(word,5) & vbcrlf & right(word,len(word)-5) & " "
else
test = test & word & " "
end if
next

--
Adrienne Boswell
Please respond to the group so others can share
http://www.arbpen.com
Jul 19 '05 #2
Your script seems to shorten each word to a maximum of 5 characters?

"Adrienne" <ar********@sbcglobal.net> wrote in message
news:Xn****************************@207.115.63.158 ...
Gazing into my crystal ball I observed al******@msn.com (Jason) writing in
news:ce**************************@posting.google.c om:
When users fill out my text area field, there is a chance that there
will be no line feeds or cariage returns or spaces and just one really
long word. THIS CAUSES A MAJOR PROBLEM! What I am trying to do is
force a vbCrLf if a string is long than 80 characters in a row. So if
a string is a total of 500 characters with no line feeds, spaces, or
returns, I want to force a vbCrLf every 80 characters so that is
doesn't overflow my preview text field on the next page.

Any suggestions on how the algorithm would be for this in VBscript
ASP?

Thanks,
Jason


How about:
for each word in split(request.form("test")," ")
if len(trim(word)) > 5 then
test = test & left(word,5) & vbcrlf & right(word,len(word)-5) & " "
else
test = test & word & " "
end if
next

--
Adrienne Boswell
Please respond to the group so others can share
http://www.arbpen.com

Jul 19 '05 #3
Dim iLoop
Dim sWorking
Dim sSection
for iLoop = 0 to len(theString) step 80
sSection=mid(theString,iLoop,80)
if instr(sSection," ") = 0 OR instr(sSection,vbCrLf)=0 then
sWorking=sWorking & sSection & vbCrLf
else
sWorking=sWorking & sSection
end if
next

"Jason" <al******@msn.com> wrote in message
news:ce**************************@posting.google.c om...
When users fill out my text area field, there is a chance that there
will be no line feeds or cariage returns or spaces and just one really
long word. THIS CAUSES A MAJOR PROBLEM! What I am trying to do is
force a vbCrLf if a string is long than 80 characters in a row. So if
a string is a total of 500 characters with no line feeds, spaces, or
returns, I want to force a vbCrLf every 80 characters so that is
doesn't overflow my preview text field on the next page.

Any suggestions on how the algorithm would be for this in VBscript
ASP?

Thanks,
Jason

Jul 19 '05 #4
http://tinyurl.com/rhyl


"Jason" <al******@msn.com> wrote in message
news:ce**************************@posting.google.c om...
When users fill out my text area field, there is a chance that there
will be no line feeds or cariage returns or spaces and just one really
long word. THIS CAUSES A MAJOR PROBLEM! What I am trying to do is
force a vbCrLf if a string is long than 80 characters in a row. So if
a string is a total of 500 characters with no line feeds, spaces, or
returns, I want to force a vbCrLf every 80 characters so that is
doesn't overflow my preview text field on the next page.

Any suggestions on how the algorithm would be for this in VBscript
ASP?

Thanks,
Jason

Jul 19 '05 #5
Gazing into my crystal ball I observed "Tom B"
<sh*****@NOSPAMhotmail.com> writing in
news:#u**************@TK2MSFTNGP10.phx.gbl:

"Adrienne" <ar********@sbcglobal.net> wrote in message
news:Xn****************************@207.115.63.158 ...
Gazing into my crystal ball I observed al******@msn.com (Jason)
writing in news:ce**************************@posting.google.c om:
> When users fill out my text area field, there is a chance that there
> will be no line feeds or cariage returns or spaces and just one
> really long word. THIS CAUSES A MAJOR PROBLEM! What I am trying to
> do is force a vbCrLf if a string is long than 80 characters in a
> row. So if a string is a total of 500 characters with no line feeds,
> spaces, or returns, I want to force a vbCrLf every 80 characters so
> that is doesn't overflow my preview text field on the next page.
>
> Any suggestions on how the algorithm would be for this in VBscript
> ASP?
>
> Thanks,
> Jason
>


How about:
for each word in split(request.form("test")," ")
if len(trim(word)) > 5 then
test = test & left(word,5) & vbcrlf & right(word,len(word)-5) & " "
else test = test & word & " "
end if
next

Your script seems to shorten each word to a maximum of 5 characters?

Just for testing. It's a little easier to test with 5 characters than 80.
YMMV.

--
Adrienne Boswell
Please respond to the group so others can share
http://www.arbpen.com
Jul 19 '05 #6
I have trouble remembering something that happened last week, and you recall
a thread from over three years ago? :>)

Bob Lehmann

"Aaron Bertrand [MVP]" <aa***@TRASHaspfaq.com> wrote in message
news:uy**************@TK2MSFTNGP12.phx.gbl...
http://tinyurl.com/rhyl


"Jason" <al******@msn.com> wrote in message
news:ce**************************@posting.google.c om...
When users fill out my text area field, there is a chance that there
will be no line feeds or cariage returns or spaces and just one really
long word. THIS CAUSES A MAJOR PROBLEM! What I am trying to do is
force a vbCrLf if a string is long than 80 characters in a row. So if
a string is a total of 500 characters with no line feeds, spaces, or
returns, I want to force a vbCrLf every 80 characters so that is
doesn't overflow my preview text field on the next page.

Any suggestions on how the algorithm would be for this in VBscript
ASP?

Thanks,
Jason


Jul 19 '05 #7
I vaguely recalled dealing with the situation before (and was surprised I
hadn't entered an article about it). Though you can easily force carriage
returns by placing text within a fixed-width table or div.

It took me about 20 minutes to find that thread, because of my initial
choice of keywords...


"Bob Lehmann" <no****@dontbotherme.zzz> wrote in message
news:uj**************@tk2msftngp13.phx.gbl...
I have trouble remembering something that happened last week, and you recall a thread from over three years ago? :>)

Jul 19 '05 #8

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

Similar topics

2
by: Paul | last post by:
Hi Doing my best to understand why I cant insert a vbcrlf or an equivalent into this piece of code that read messages from an SQL DB. The messages it takes read into a marquee fine but I want...
4
by: Niyazi | last post by:
Hi I am trying to insert some value into SQL Server 2000 tables and I am keep getting the "Input string was not in a correct format" error. When user fills the Form it updates the table call...
8
by: **Developer** | last post by:
ControlRichTextBox1.SelectedText = String.Format("{0} {1}", strExt, x.szTypeName) & vbCrLf Three questions: 1) How can I insert a tab between {0} and (1} so the richtextbox tabs...
6
by: =?Utf-8?B?cm9nZXJfMjc=?= | last post by:
hey, I have a bunch of strings that are 20 characters long. The user inputs data 10 characters long and I am inserting data at character spot number 11. well what if the user inputs data that is...
4
by: alfred | last post by:
Hi everyone, I have a problem. I have create a string (its name is book) and i want to insert the books with this text formatting: First book Second book third book ecc.... with the end of...
1
by: kellysgirl | last post by:
Now what you are going to see posted here is both the set of instructions I was given..and the code I have written. The instructions I was given are as follows In this case, you will create...
3
by: wildman | last post by:
Is there any way for gridview cells to observe vbcrlf in the data? I attempted to do this, but it does not seem to work. Dim dgItem As GridViewRow For Each dgItem In gridCollaborator.Rows...
8
by: drjay1627 | last post by:
hello, This is my 1st post here! *welcome drjay* Thanks! I look answering questions and getting answers to other! Now that we got that out of the way. I'm trying to read in a string and...
11
by: blunt | last post by:
trying to write a program to write the configuration files for a load of wireless access points. i've never been a good programmer and haven't done any for nearly a decade so have obviously made some...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.