If he doesn't have a DB to save the form field value(s) to then all the more reason to not bother to split anything
If he displays the form results he has to rebuild x parts (x is unknown w/o a correct Ubound )
- same apllies w/ Email of form results
(yet both would display or be sent by Email as entered w/o doing a split)
While not required, I use defensive coding
One reason for the instr test in my code is to determine if there is more than 1 part at all
- since there is no need to split or do an Ubound on 1 paragraph
(and the field count varies because of the way arrays parts are numbered)
In any event, I still don't understand any valid reasons for doing the split
But if it is just for display the code would be:
<%
message_text_value= Request.Form("textfieldname")
IF Instr(message_text_value, vbCrLf)>0 THEN
msgText = Split(message_text_value, vbCrLf)
msgFields = Ubound(msgText)
For N=0 to Ubound(msgText)
msgPart=msgText(N)
If Len(msgPart)>0 Then
Response.Write "<p>" & N+1 & ") " & msgPart & "</p>"
Else
Response.Write "<p>" & N+1 & ") - No Data Entered" & "</p>"
End if
Next
Else
msgFields=1
msgPart = message_text_value
If Len(msgPart)>0 Then
Response.Write "<p>" & msgFields & ") " & msgPart & "</p>"
Else
Response.Write "<p>" & msgFields & ") - No Data Entered" & "</p>"
End if
End If
%>
--
_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________
| Unless I've misunderstood his post he doesn't have a database atall.
| Ultimately he wants to email the results. In which case he could just use
| split as
|
| text=request.form("textfield")
| Paras=split(text,vbCrLf)
|
| which would give
| Paras(0) ' first paragraph
| Paras(1) ' second paragraph
| etc
| ubound(Paras) + 1 ' Number of paragraphs.
|
| There's no need to check if the string contains vbCrLf - if you try to split
| on something that isn't contained in the string there won't be an error
| ubound(ArrayName) will just return 0
|
| Cheers,
| Jon
|
| | > You can try the split function
| > See
http://www.w3schools.com/vbscript/func_split.asp
| > - you man need a binary compare
| >
| > As say
| > <%
| > if instr(message_text_value, vbCrLf)>0 then
| > msgText = split(message_text_value, vbCrLf) 'creates an array
| > msgFields = Ubound(msgParts) +1
| > ' 0 means 1 part because array numbers start w/ 0, 1 for 2 parts, 2
| > for 3 parts, etc
| > 'write the number of fields found using msgFields
| > For N = 0 to Ubound(msgParts)
| > msgPart=msgText(N) 'get teh parts
| > 'write the field part using msgPart to DB field(N+1)
| > Next
| > else 'only 1 paragraph
| > msgText = message_text_value
| > msgFields = 1
| > 'write the number of fields found (1) using msgFields
| > 'write the field part using just msgText to DB to field 1 (no other
| > parts)
| > end if
| >
| > %>
| >
| > But your whole approach of splitting is problematic because you will not
| > know each time how many paragraphs are there, thus the # of
| > fields to write/read will vary, and some may be empty for double line
| > breaks, and you will also need to write the # of fields w/
| > each different result (you could have scores of new fields and never know
| > if you have enough in the DB
| > IMHO
| > Don't split the data, as the splits are arbitrary and meaningless, thus
| > yielding many meaningless DB fields
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > _____________________________________________
| >
| >
| > | > | That doesn't return just the first paragraph, then the second
| > | separately. It returns the entire field. I want to separate or split
| > | out each paragraph and return as separate.
| > |
| > |
| > | > Try this.
| > | >
| > | > message_text_value =
| > | > Replace(Server.HTMLEncode(Request.Form("message_text")), vbCrLf,
| > "<p>")
| > | >
| > | > response.write message_text_value
| > | >
| > | > --
| > | > David Berry
| > | > Microsoft MVP - FrontPage
| > | > FrontPage Support:
http://www.frontpagemvps.com/
| > | > -----------------------------------
| > | > To assist you in getting the best answers for FrontPage support
| > see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| > | > -----------------------------------
| > | >
| > | >
| > | > | > | >
| > | >
| > | >
| > | > >I guess I wasn't totally clear when I stated I wanted to separate out
| > | > > each paragraph. What I need to do is separate it so thatI'll end up
| > | > > with a variable I'll call paragraph where:
| > | > > paragraph(1) = the first paragraph of message_text_value
| > | > > paragraph(2) = the second paragraph of message_text_value
| > | > > and so on
| > | >
| > | > > That was why I was asking about possibly using the function "split"
| > | > > and was figuring if I somehow could search for the line breaks using
| > | > > some other string function, could then maybe split it where ever I
| > | > > found a line break? That's what I want to do, but not sure how to
| > do
| > | > > it particually how to find where the line breaks are located and
| > then
| > | > > somehow split it out?
| > | >
| > | > > Hopefully that clears it up better. Sorry for confusion.
| > | >
| > | > > On Apr 10, 3:53 pm, "Kevin Spencer" <
[email protected]>
| > wrote:
| > | > >> In Dave's example, just replace the "objRS("message_text") with
| > | > >> Request.Form("message_text"). In either case, you're just replacing
| > line
| > | > >> breaks in (some text) with "<br />" elements.
| > | >
| > | > >> --
| > | > >> HTH,
| > | >
| > | > >> Kevin Spencer
| > | > >> Microsoft MVP
| > | >
| > | > >> Printing Components, Email Components,
| > | > >> FTP Client Classes, Enhanced Data Controls, much more.
| > | > >> DSI PrintManager, Miradyne Component
| > Libraries:
http://www.miradyne.net
| > | >
| > | >
| > | > >>| > | >
| > | > >> > This isn't in a database. This is a message field that will
| > | > >> > eventually become the message of an email. Before the email is
| > sent
| > | > >> > though I'm attempting to do some text manipulation, therefore I
| > want
| > | > >> > to break it out into paragraphs. So this is just being passed to
| > me
| > | > >> > as: message_text_value = Request.Form("message_text") Now am
| > trying
| > | > >> > to manipulate the variable message_text_value into separate
| > paragraphs
| > | > >> > if needed.
| > | >
| > | > >> >> In ASP, you can do a search for the CRLF character and replace
| > it with
| > | > >> >> a
| > | > >> >> "<p>" or "<br>". That should be how the line breaks are stored
| > in
| > | > >> >> Access.
| > | >
| > | > >> >> If the DB field is named message_text and your recordset is
| > called
| > | > >> >> objRS
| > | > >> >> then when you retrieve the information from the database you
| > would do:
| > | >
| > | > >> >> <%=Replace(objRS("message_text"), vbCrLf,"<br>")%>
| > | >
| > | > >> >> You can use either <br> for a single line return or <p> for
| > double
| > | > >> >> line
| > | > >> >> return
| > | >
| > | > >> >> --
| > | > >> >> David Berry
| > | > >> >> Microsoft MVP - FrontPage
| > | > >> >> FrontPage Support:
http://www.frontpagemvps.com/
| > | > >> >> -----------------------------------
| > | > >> >> To assist you in getting the best answers for FrontPage support
| > | > >> >>
| > see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| > | > >> >> -----------------------------------
| > | >
| > | > >> >> message| > | > >> >> I have a free form field that people fill in and submit.
| > Their
| > | > >> >> responses can be from a sentence or two, to one long paragraph,
| > to
| > | > >> >> multi-paragraphs. For downstream reasons, if they enter
| > multiple
| > | > >> >> paragraphs, I need to be able to separate each paragraph out.
| > Reading
| > | > >> >> some, it sounds like I may be able to use the split function in
| > | > >> >> conjunction with searching for the line field character. The
| > problem
| > | > >> >> though is not exactly sure how to accomplish that task.
| > | >
| > | > >> >> So if my field is called message_text, how would I best be
| > able to
| > | > >> >> separate out and return each paragraph as a separate entity?
| > What
| > | > >> >> would the code need to look like, either as I suggested above or
| > other
| > | > >> >> method?
| > | >
| > | > >> >> Any suggestions? Thanks!- Hide quoted text -
| > | >
| > | > >> - Show quoted text -- Hide quoted text -
| > | >
| > | > - Show quoted text -
| > |
| > |
| >
| >
|
|