[thelist] Stripping two VbCrLfs

Chris Blessing webguy at mail.rit.edu
Thu Mar 21 14:24:00 CST 2002


Along with replace(), you could use this as well:

<%
dim strLineOfText
strLineOfText = "Line of text." & vbcrlf & vbcrlf & vbcrlf

' note that for some reason, vbcrlf = vblf in the above text.
' VBS seems to do this a lot, so you may need to check for both chr(10) and
chr(13)
do while right(strLineOfText,1) = chr(10) or right(strLineOfText,1) =
chr(13)
	' as long as there is a line-feed at the end of the string, lop it off
	strLineOfText = left(strLineOfText, len(strLineOfText)-2)
loop

' add one line feed to the end
strLineOfText = strLineOfText & vbcrlf

' view the source of the resulting HTML to see:
' <P>BEGIN<BR>Line of text.
' <BR>END

response.write("<P>BEGIN<BR>" & strLineOfText & "<BR>END")
%>

Using the replace() method is much easier (obviously) but if you have any
other need for a double-line-feed in the text itself, it too will become a
single line-feed, so watch out! =)

Chris Blessing
webguy at mail.rit.edu
http://www.330i.net

> -----Original Message-----
> From: thelist-admin at lists.evolt.org
> [mailto:thelist-admin at lists.evolt.org]On Behalf Of Charles Roper
> Sent: Thursday, March 21, 2002 2:47 PM
> To: thelist at lists.evolt.org
> Subject: [thelist] Stripping two VbCrLfs
>
>
> Hi,
>
> I'm writing to a text file using the FileSystemObject in ASP/VBscript by
> submitting a form with a textarea. How do I strip out two instances of
> VbCrLf when writing to the text file and replace it with just the one
> VbCrLf? What's happening is when a user hits return twice to create a
> paragraph in the text area, it's inserting two VbCrLfs, whereas I need
> the text file to have only one VbCrLf after each paragraph.
>
> So, for example, this is what the text file is being written like now:
>
> Line of text
>
> Line of text
>
> Line of text
>
> But I want it to be written like so:
>
> Line of text
> Line of text
> Line of text
>
> Preferably I'd like to replace the VbCrLfs when writing to the file
> rather than reformatting it after it's been written.
>
> Thanks in advance.
>
> Charles Roper
>
>
>
> --
> For unsubscribe and other options, including
> the Tip Harvester and archive of thelist go to:
> http://lists.evolt.org Workers of the Web, evolt !




More information about the thelist mailing list