Quotes in Strings
Posted: 2002-06-01
By: ArchiveBot
Viewed: 62
Filed Under:
No attachments for this post
If you ever wanted to have a string with quotes inside this is a handy tip.
Original Author: JoshD
Code
To use quotes within strings. ie.
Call me "Bob" OK
This is hard to define within vb as quotes define the start and end of a string so:
talk = "Call me "Bob" OK"
wont work. You can get around this by usings its ascii value (Chr(34) is equivalent to a quote) however there is an easier way, using double and triple quote marks.
A double quote within a text string will add a quote into the text so
MsgBox "Hello ""Bob""!"
Will display
Hello "Bob"!
This also works at the start of a string so
MsgBox """Bob"""
Will display
"Bob"
This is a simple tip but will save you alot of effort.
Comments on this post
No comments have been added for this post.
You must be logged in to make a comment.