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

Discussion in 'ASP General' started by Jason, Oct 19, 2003.

  1. Jason

    Jason Guest

    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
    Jason, Oct 19, 2003
    #1
    1. Advertising

  2. Jason

    Adrienne Guest

    Gazing into my crystal ball I observed (Jason) writing in
    news::

    > 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
    Adrienne, Oct 19, 2003
    #2
    1. Advertising

  3. Jason

    Tom B Guest

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

    "Adrienne" <> wrote in message
    news:Xns9418F214064EAarbpenyahoocom@207.115.63.158...
    > Gazing into my crystal ball I observed (Jason) writing in
    > news::
    >
    > > 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
    Tom B, Oct 19, 2003
    #3
  4. Jason

    Tom B Guest

    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" <> wrote in message
    news:...
    > 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
    Tom B, Oct 19, 2003
    #4
  5. http://tinyurl.com/rhyl






    "Jason" <> wrote in message
    news:...
    > 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
    Aaron Bertrand [MVP], Oct 19, 2003
    #5
  6. Jason

    Bob Lehmann Guest

    I have trouble remembering something that happened last week, and you recall
    a thread from over three years ago? :>)

    Bob Lehmann

    "Aaron Bertrand [MVP]" <> wrote in message
    news:...
    > http://tinyurl.com/rhyl
    >
    >
    >
    >
    >
    >
    > "Jason" <> wrote in message
    > news:...
    > > 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

    >
    >
    Bob Lehmann, Oct 19, 2003
    #6
  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" <> wrote in message
    news:...
    > I have trouble remembering something that happened last week, and you

    recall
    > a thread from over three years ago? :>)
    Aaron Bertrand - MVP, Oct 20, 2003
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Patrick Olurotimi Ige
    Replies:
    2
    Views:
    477
    Patrick Olurotimi Ige
    May 5, 2005
  2. Ouabaine

    Cariage return

    Ouabaine, Jan 17, 2008, in forum: Java
    Replies:
    2
    Views:
    310
    Roedy Green
    Jan 17, 2008
  3. Replies:
    3
    Views:
    4,895
    Peter Bromberg [C# MVP]
    Mar 6, 2008
  4. John B. Matthews
    Replies:
    4
    Views:
    655
    John B. Matthews
    Sep 12, 2008
  5. Roedy Green
    Replies:
    3
    Views:
    613
Loading...

Share This Page