Search code examples
vb.netescapingcharacterquotations

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


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.


Solution

  • 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