tags:

views:

70

answers:

3

Hi, how many " (double quotes) do I put around this line so that I end up with ="08075" being pasted into my excel worksheet? The line is:

Response.Write vbTab & ResultSet(8,r)

I need and '=' sign with a single quote before the ResultSet(8,r) with a closing double quote after... I tried:

Response.Write vbTab & "="" & ResultSet(8,r) & """

but that didn't work, plus a couple others but that didn't work, the number of quotes thing always gets me so if someone wants to give me a general rule of thumb on this one I would really appreciate it.

Thanks, R.

+1  A: 

Wouldn't you know, I just cracked it:

Response.Write vbTab & "=""" & ResultSet(8,r) & """"

Thanks, R.

flavour404
Funny how a simple syntax highlighter (even the SO one) reveals the answer.
Frank Krueger
+3  A: 

To get a literal double quote (") inside of a string in VBScript, you need to use two double quotes (""). So for your example:

Response.Write vbTab & "=""" & ResultSet(8,r) & """"
'                      ^   ^                    ^  ^ These delimit the string
'                        ^^                      ^^  These create literal quotes
Sean Bright
Thanks, i'll keep that in mind.
flavour404
A: 

Double each quote you want to end up in the string. So what you want would be:

Response.Write vbTab & "=""" & ResultSet(8,r) & """"
Brian Schantz