Archive of Mr Excel Message Board


Back to Excel VBA archive index
Back to archive home





VBA - " double quote within the string variable

Posted by Mindy on May 31, 2001 8:50 AM
How do I assign the " into the string in the macro?

ex:

dim String as string

String = "This is the Test only." & """ & "double ok" & """ & "."


The string output value I am looking for is something like
this

This is the test "double ok".


""" does not work for me, what else should I try.

Thank you for helping


Check out our Excel VBA Resources

Re: VBA -

Posted by Russell on May 31, 2001 8:55 AM


The way I like is to include chr(34), which is the double quote.

For example,

str = chr(34) & "There should be a double quote before and after this sentence" & chr(34)

str should equal "There should be a double quote before and after this sentence" (with quotes included).


Re: VBA - " double quote within the string variable

Posted by Mindy on May 31, 2001 8:55 AM


Sorry, I found the solution now.

I can use

String = "This is the Test only." & chr(34) & "double ok" & chr(34) & "."



Re: VBA - " double quote within the string variable

Posted by dax on May 31, 2001 8:56 AM

Hello,

Try using Chr(34) which return the character associated with the specified ASCII code - in this case the "

S = "This is the Test only." & Chr(34) & "double ok" & Chr(34) & "."


HTH,
Dax.


Re: VBA - " double quote within the string variable

Posted by asf on May 31, 2001 8:59 AM





This archive is from the original message board at www.MrExcel.com.
All contents © 1998-2004 MrExcel.com.
Visit our online store to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.