tags:

views:

93

answers:

4

I am trying to remove all the " from a string called s1, I have this line

s1=replace (s1, """, "")

But I get a compile error saying it is expecting a list separator or )

How can I fix it? Thanks in advance.

+7  A: 

Your second string isn’t properly delimited. If you want to use a quotation mark (") inside your string, you need to double it. Since your string only consists of a quotation mark, it looks as follows:

  • Quotation mark to start the string, ".
  • Double quotation mark that represents a single quotation mark inside the string, "".
  • Ending quotation mark, ".

In summary:

s1 = Replace(s1, """", "")
Konrad Rudolph
A: 

Did you really write """? You have to escape the " in the middle - just double it like:

replace( s1, """", "" )
tanascius
+4  A: 

Konrad's suggestion is the one you should go with, but here's another for completeness/amusement.

s1 = Replace(s1, Chr(34), "")

And if you ever get bored at a party and need something to read on your phone, here's the list of the 256 such ASCII codes you can use with Chr().

http://msdn.microsoft.com/en-us/library/4z4t9ed1%28v=VS.80%29.aspx

danyal
A: 

Commonly used syntaxes are:

s1=replace (s1, "\"", "")
s1=replace (s1, """", "")
s1=replace (s1, '"', "")
AareP
Only `""""` works in VB6
MarkJ
Yeah, but it's good to know all possible notations just in case.. It's not like our brain would overflow with information :)
AareP