Format line so that I end up with =“08075”

2019-07-24 16:02发布

问题:

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.

回答1:

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


回答2:

Wouldn't you know, I just cracked it:

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

Thanks, R.



回答3:

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

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


标签: asp-classic