How to concatenate double quotes

X

xRoachx

I need to concatenate a string with double quotes but I
can't get it quite right:

strTempAppType = """ & cboAppTypes.Text & """

So if cboAppTypes.Text was NORTH, I want strTemAppType to
be equal to "NORTH", including the quotes. What is the
correct syntax? Thanks.
 
A

Allen Browne

If you type:
"This "word" is in quotes" '<= Error!
VBA thinks the string ends when it hits the quote mark before Word, and then
has no idea what to do with the rest of the line. Therefore a quote inside
quotes has to be doubled, i.e.:
"This ""word"" is in quotes"

So, if you have nothing but a quote mark inside quotes, and it has to be
doubled, you end up with:
""""

Try:
strTempAppType = """" & cboAppTypes.Text & """"
 
X

xRoachx

That did the trick. Thanks for the info!
-----Original Message-----
If you type:
"This "word" is in quotes" '<= Error!
VBA thinks the string ends when it hits the quote mark before Word, and then
has no idea what to do with the rest of the line. Therefore a quote inside
quotes has to be doubled, i.e.:
"This ""word"" is in quotes"

So, if you have nothing but a quote mark inside quotes, and it has to be
doubled, you end up with:
""""

Try:
strTempAppType = """" & cboAppTypes.Text & """"

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.




.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top