TheDesignspace
Escape double quotes in strings in Visual Basic


February 25, 2009
ASP | Web Building | Most Popular

I use Javascript much more than visual basic, so I've always been puzzled by how to escape nested quotes in strings in VB. In Javascript, you either nest single quotes (apostrophe's) and double quotes or add a backslash to escape the character (\", \'). But in VB, single quotes create a comment, and backslashes do not escape characters, so I've been using all sorts of tricks to try and avoid the situation.

Thanks to a discussion on this forum thread, I found that it's simple. Just use "" instead of " to escape the nested quote. In other words, just double up the double quote symbol, to have it ignored in calculating the end of the string.

Posted by ellen at February 25, 2009 07:03 PM | TrackBack

No Comments

Leave a comment





  Subscribe in a reader

 Contact Me