Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add double quotes in a string literal

Example code:

Dim a As String
a = 1234,5678,9123

I want to add literal double quotes to the variable a

Expected Output:

a = "1234,5678,9123"

How do I format the string so when I print it, it has double quotes around it?

like image 975
Gopal Avatar asked Dec 20 '11 11:12

Gopal


People also ask

How can I add double quotes to a string that is inside a variable?

Use a formatted string literal to add double quotes around a variable in Python, e.g. result = f'"{my_var}"' . Formatted string literals let us include variables inside of a string by prefixing the string with f .

How do you add double quotes to a string in C++?

To have a double quote as a character in a string literal, do something like, char ident[] = "ab"cd"; The backslash is used in an escape sequence, to avoid conflict with delimiters. To have a double quote as a character, there is no need for the backslash: '”' is alright.

How do you add double quotes to a string variable in Java?

You can add double quotes to a string variable by using escape character symbol “\”. Using this symbol will notify the JVM to ignore the extra quotes around the text. All that you need to do is to add “\” in-front of the text and \”” at the end.

How to add double quotes to a string in C++?

Suppose, if we want to add double quotes to a string then we need [ "] escape sequence to escape quotes. Let us suppose if we have a string "Preeti" and simply it will display like this preeti and if we want to add double quotes to string (i.e. display like "preeti" ) then we will write a statement like this ""Preeti"".

How to add double quotes to Oops in Java?

// For adding double quotes to OOPS // then we need or add " escape sequence to escape quotes // around both side string. String str2 = " " OOPS " "; System. out. println ("Display String without quotes " + " " + str1); System. out. println ("Display String with quotes " + " " + str2); } }

How to escape a double quote from a string in Python?

u want like this right “vchkey” in the output You can escape a double quote by prefixing it with another. For instance, you need to print a string “Number” with the quotes. Use WriteLine and put the String as: “”“Number”"".

How to include a quote in a string?

If you want to include " in a string, supply "" where you want the quote to appear. So your example should read... The current answers are correct and valid but sometimes the following can improve readability: I didn't down-vote, but that is NOT more readable! Are all developers expected to know the entire ASCII character code set?


2 Answers

If you want to include " in a string, supply "" where you want the quote to appear. So your example should read...

a = """1234,5678,9123"""
like image 194
Brian Hooper Avatar answered Oct 07 '22 09:10

Brian Hooper


To make Chr$(34) more readable:

Dim quote as string
quote = Chr$(34)
a = quote & "1234,5678,9123" & quote

This makes it easier to get the correct number of " symbols everywhere and is readable.

like image 44
MikeF Avatar answered Oct 07 '22 09:10

MikeF