|
Home > Archive > IIS ASP > April 2005 > Remove Carriage Returns
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Remove Carriage Returns
|
|
| Simon Harris 2005-04-27, 5:57 pm |
| Hi All,
I am trying to write a function that will remove all carriage returns from
a
string, so that the string of words can be used as meta keywords.
So far I have:
Function RemoveCR(strText)
strText = Replace(strText,chr(13),"")
strText = Replace(strText,chr(10),"")
strText = Replace(strText,vbCrLf ,"VISUALBASIC")
RemoveCR = strText
End Function
My string still ends up with carriage returns in it though! I don't get
it,
what did I miss?
Thanks,
Simon.
--
I am using the free version of SPAMfighter for private users.
It has removed 2054 spam emails to date.
Paying users do not have this message in their emails.
Try www.SPAMfighter.com for free now!
| |
| Kyle Peterson 2005-04-27, 5:57 pm |
| well, that looks pretty good really at 1st glance but it must be missing
something ?
I usually just do this in my own code when I log inot ot a text file and it
usually gets everything for me
You might want to try checking to 3 things my function looks for
The reason why I have a fix part is because I sometimes have many scenarios
in my function and this way I can have one function that can do a bunch of
things
Function FixStr(StrToFix,FixHow)
If Not IsNull(StrToFix) and StrToFix <> "" Then
If FixHow = "PrepareForLogfile" then
StrToFix = Replace(StrToFix,vbCrLf," ")
StrToFix = Replace(StrToFix,vbLf," ")
StrToFix = Replace(StrToFix,vbNewLine," ")
End If
End If
FixStr = StrToFix
End function
FixStr(Request("address_street"),"PrepareForLogfile")
"Simon Harris" <too-much-spam@makes-you-fat.com> wrote in message
news:ek$wyZ3SFHA.2812@TK2MSFTNGP09.phx.gbl...
> Hi All,
>
> I am trying to write a function that will remove all carriage returns from
> a
> string, so that the string of words can be used as meta keywords.
>
> So far I have:
>
> Function RemoveCR(strText)
> strText = Replace(strText,chr(13),"")
> strText = Replace(strText,chr(10),"")
> strText = Replace(strText,vbCrLf ,"VISUALBASIC")
> RemoveCR = strText
> End Function
>
> My string still ends up with carriage returns in it though! I don't get
> it,
> what did I miss?
>
> Thanks,
> Simon.
>
>
> --
> I am using the free version of SPAMfighter for private users.
> It has removed 2054 spam emails to date.
> Paying users do not have this message in their emails.
> Try www.SPAMfighter.com for free now!
>
>
| |
| Dave Anderson 2005-04-27, 8:51 pm |
| Simon Harris wrote:
> I am trying to write a function that will remove all carriage returns
> from a
> string, so that the string of words can be used as meta keywords.
In that case, would it be acceptible to replace all whitespace characters
with spaces? You could do that with a Regular Expression...
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
| |
| Bob Barrows [MVP] 2005-04-28, 7:55 am |
| Simon Harris wrote:
> Hi All,
>
> I am trying to write a function that will remove all carriage returns
> from a
> string, so that the string of words can be used as meta keywords.
>
> So far I have:
>
> Function RemoveCR(strText)
> strText = Replace(strText,chr(13),"")
> strText = Replace(strText,chr(10),"")
> strText = Replace(strText,vbCrLf ,"VISUALBASIC")
> RemoveCR = strText
> End Function
>
> My string still ends up with carriage returns in it though! I don't
> get it,
> what did I miss?
>
The first two lines are overkill. In fact, they will prevent the third line
from doing anything. vbCrLf is a constant that is equivalent to chr(13) &
chr(10).
I guess we need to see strText in order to see what is wrong. Are you sure
it does not contain html? Particularly "<BR>"?
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
| |
| Simon Harris 2005-04-29, 6:13 pm |
| Hi,
Many thanks for the replies.
Seems I was calling my function incorrectly, or at the wrong time.
Simon.
|
|
|
|
|