views:

659

answers:

2

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.

+2  A: 

In VB (which is what the code sample is in), the escape character is double quotes. So it would be

robert = Replace(robert, """", "A")
Todd Gardner
why was this down voted?
Jonathan Fingland
@Jonathan: If you upvoted to balance things out I must say that's mighty classy of you. I've seen others downvote just to push their answers to the top.
Adam Bernier
I didn't up vote it, though perhaps I should have. Shortly after my comment, it was back to zero. I assumed who ever down voted had removed it. I almost never up vote/down vote in the same questions where I have a competing answer. If I up vote it, it's because I think it's a better answer and I usually delete my own. If I think their answer is worse, I just leave it alone.
Jonathan Fingland
I agree. However, I wouldn't be so quick to delete a post. I understand your point, but I would think that your post would have some good background info; or perhaps a different way of looking at the problem. People like you and Todd are what make SO a great place. Keep up the great work.
Adam Bernier
+6  A: 

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

Jonathan Fingland