How to use escape character in replace function when replacing quotations in VB

Robert picture Robert · Jun 7, 2009 · Viewed 11.5k times · Source

Here is my code snippet:

 Public Function convert(ByVal robert As String)
        Try
            robert = Replace(robert, "U", "A")
            robert = Replace(robert, "\"", "A")

I want to actually replace the "quotations" with the A but the program doesn't seem to recognize the fact that I'm using an escape character in VB. Does anyone know why? Thanks!

Robert

EDIT by rlbond86: This is clearly Visual Basic code. I have changed the title and text to reflect that.

Answer

Jonathan Fingland picture Jonathan Fingland · Jun 7, 2009

Looks like VB, not c++.

See http://www.codingforums.com/archive/index.php/t-20709.html

you want to use:

robert = Replace(robert, chr(34), "A")

or

robert = Replace(robert, """", "A")

using " as escape character

also see: http://www.codecodex.com/wiki/index.php?title=Escape_sequences For info on escape sequences in multiple languages