473,396 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Remove Carriage Returns

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!
Jul 22 '05 #1
4 13834
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"),"PrepareForLogfil e")
"Simon Harris" <to***********@makes-you-fat.com> wrote in message
news:ek**************@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!

Jul 22 '05 #2
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.
Jul 22 '05 #3
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.
Jul 22 '05 #4
Hi,

Many thanks for the replies.

Seems I was calling my function incorrectly, or at the wrong time.

Simon.
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Les Juby | last post by:
Can someone please help with a suggestion as to how I can keep the formatting (carriage returns) that the user enters into a memo field and then display that later. I figured I might be able to...
2
by: lauren quantrell | last post by:
Has anyone cunstructed a function to remove multiple carriage returns and replace it with a single return? Replace(mytext, Chr(13) & Chr(10) & Chr(13) & Chr(10), Chr(13) & Chr(10)) ... only...
2
by: eagleofjade | last post by:
I am trying to import data from a Word document into an Access table with VBA. The Word document is a form which has various fields. One of the fields is a field for notes. In some cases, this...
2
by: Matt Mercer | last post by:
Hi all, I am having a frustration problem, and I have read about 25 newsgroup postings that do not have a satisfying answer :) The problem appears to be common where carriage returns are lost...
8
by: TheDude5B | last post by:
Hi, I have some data which is stored in my MySQL database as TEXT. when the data is entered in, it has some carriage returns in it, and this can be seen when querying the data using MySQL Query...
7
by: mattrapoport | last post by:
I have a page with a div on it. The div displays a user comment. When the user logs into this page, their current comment is pulled from a db and displayed in the div. The user can edit the...
0
by: markus.shure | last post by:
Hi, I'm noticed a problem testing a JAX-WS client with a WSE server. The JAX-WS client adds carriage returns to a SOAP header element that is signed. This causes the WSE server to raise an...
7
by: newbtemple | last post by:
Hey all. I'm having a bugger of a time trying to remove carriage returns. I have a large text file with a bunch of little squares. I'm guessing they're carriage returns from what i've googled. They...
11
by: evenlater | last post by:
My db allows the user to send email via CDO. The body of the email is determined in code. I have built an email form with To, CC and Subject lines and a large text box for the body of the message...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.