I have this code:
a = "xyz"
g = "abcd " & a
After running it, the value of g
is abcd xyz
.
However, I want quotes around the value of a
in g
. After running the code, g
should be abcd "xyz"
instead.
How can I accomplish this?
I have this code:
a = "xyz"
g = "abcd " & a
After running it, the value of g
is abcd xyz
.
However, I want quotes around the value of a
in g
. After running the code, g
should be abcd "xyz"
instead.
How can I accomplish this?
You can escape by doubling the quotes
or write an explicit
chr()
callI designed a simple approach using single quotes when forming the strings and then calling a function that replaces single quotes with double quotes.
Of course this approach works as long as you don't need to include actual single quotes inside your string.
...
...
Hope this helps.
I found the answer to use double and triple quotation marks unsatisfactory. I used a nested DO...LOOP to write an ASP segment of code. There are repeated quotation marks within the string. When I ran the code:
the output was: <`asp:RectangleHotSpot Bottom="28
The output:
I don't think I can improve on these answers as I've used them all, but my preference is declaring a constant and using that as it can be a real pain if you have a long string and try to accommodate with the correct number of quotes and make a mistake. ;)
The traditional way to specify quotes is to use
Chr(34)
. This is error resistant and is not an abomination.You can do like:
Or: