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

Ask a Question related to ASP, Design and Development.

  1. #1

    Default 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
    Jason Guest

  2. Similar Questions and Discussions

    1. Spaces/line breaks appear in Contribute
      I'm seeing extra line breaks/line feeds when browsing and editing a table filled with addresses and phone numbers in Contribute. The page appears...
    2. Getting ride of Line Feeds
      I have code that reads data from a text document. Here is one name it returned: Sweeny, Katherine Michell e Notice there is a break in 'Michelle'...
    3. replace spaces with 0's in a string
      I have a string like this '00023MJKOP16598 09 00' I need to replace spaces in this string with zeros so that the spaces are gone. So it would...
    4. line spaces in imported text
      I'm trying to loadvars into my flash project, but the text I'm trying to load has spaces in it, which doesn't load in right.. for example: ...
    5. Line Feeds in Datagrid
      Dear all, I'm using a datagrid in a c# asp.net page to display data from a dataset populated from my SQL Server. So far, so good! :-) The...
  3. #2

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

    Gazing into my crystal ball I observed [email]alihamed@msn.com[/email] (Jason) writing in
    news:ce214430.0310182205.10363d4e@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
    [url]http://www.arbpen.com[/url]
    Adrienne Guest

  4. #3

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

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

    "Adrienne" <arbpen2003@sbcglobal.net> wrote in message
    news:Xns9418F214064EAarbpenyahoocom@207.115.63.158 ...
    > Gazing into my crystal ball I observed [email]alihamed@msn.com[/email] (Jason) writing in
    > news:ce214430.0310182205.10363d4e@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
    > [url]http://www.arbpen.com[/url]

    Tom B Guest

  5. #4

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

    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" <alihamed@msn.com> wrote in message
    news:ce214430.0310182205.10363d4e@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

    Tom B Guest

  6. #5

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

    [url]http://tinyurl.com/rhyl[/url]






    "Jason" <alihamed@msn.com> wrote in message
    news:ce214430.0310182205.10363d4e@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

    Aaron Bertrand [MVP] Guest

  7. #6

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

    Gazing into my crystal ball I observed "Tom B"
    <shuckle@NOSPAMhotmail.com> writing in
    news:#uHLQEklDHA.2080@TK2MSFTNGP10.phx.gbl:
    >
    > "Adrienne" <arbpen2003@sbcglobal.net> wrote in message
    > news:Xns9418F214064EAarbpenyahoocom@207.115.63.158 ...
    >> Gazing into my crystal ball I observed [email]alihamed@msn.com[/email] (Jason)
    >> writing in news:ce214430.0310182205.10363d4e@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
    [url]http://www.arbpen.com[/url]
    Adrienne Guest

  8. #7

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

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

    Bob Lehmann

    "Aaron Bertrand [MVP]" <aaron@TRASHaspfaq.com> wrote in message
    news:uyj3hMmlDHA.2404@TK2MSFTNGP12.phx.gbl...
    > [url]http://tinyurl.com/rhyl[/url]
    >
    >
    >
    >
    >
    >
    > "Jason" <alihamed@msn.com> wrote in message
    > news:ce214430.0310182205.10363d4e@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
    >
    >

    Bob Lehmann Guest

  9. #8

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

    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" <nospam@dontbotherme.zzz> wrote in message
    news:ujuEvxnlDHA.3288@tk2msftngp13.phx.gbl...
    > I have trouble remembering something that happened last week, and you
    recall
    > a thread from over three years ago? :>)

    Aaron Bertrand - MVP Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139