Thursday, 6 March 2008

Replacing double quotes in VB strings

If you're forced to use VB and some of us occasionally you'll end up at some point wanting to get rid of the double quotes in a string. More as a note to myself this one but here's the help..

The way to do that is replace instances of " with "".
Sample code -

Dim str As String = "I ""love"" VB"
Console.WriteLine(str)
Console.WriteLine(str.Replace("""", ""))

now relax, job done, compile and move away.

No comments: