Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

replace double quote by single quote 1

Status
Not open for further replies.

henryz

Programmer
Oct 3, 2001
33
AU
Hello Everybody,

I have a funny experience. In a case I want to replace all double quotes in
my data content by single quotes. I use function like this:

Function StrQuoteReplace(strValue)
// Replace any double quote in strValue with one single quote.
// The second argument to Replace consists of
// one double quote enclosed in a pair of double quotes.
// The third argument to Replace consists of
// one single quote enclosed in a pair of double quotes.
StrQuoteReplace = Replace(strValue, " " ", " ' ")

End Function

but I don't know for some reason the code does not work, I have a compile
error, the message is in the following:

"Microsoft VBScript compilation error '800a03ee'

Expected ')'

StrQuoteReplace = Replace(strValue, """, "'")
------------------------------------------^"

Any Suggestions will be most welcome.

Thanks in advance

Henry




 
Don't you need a forward slash infront of the " inside the quote marks, or it thinks you're closing the string and opening one again without closing it. I'm a Java guy not VB but I guess the principals the same, try "/"" I think that's right.
 
Dear xscape,

It does not work as you suggested. Thanks a lot anyway.

Henry
 
Because you are placing a double quote within double quotes, you need to use two. This will work:

StrQuoteReplace = Replace(strValue, """", "'")
Mise Le Meas,

Mighty :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top