VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Quotes in Strings

by JoshD (13 Submissions)
Category: String Manipulation
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

If you ever wanted to have a string with quotes inside this is a handy tip.

Rate Quotes in Strings

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.

Download this snippet    Add to My Saved Code

Quotes in Strings Comments

No comments have been posted about Quotes in Strings. Why not be the first to post a comment about Quotes in Strings.

Post your comment

Subject:
Message:
0/1000 characters