ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do you include a quotation as part of a string ?? (https://www.excelbanter.com/excel-programming/376699-how-do-you-include-quotation-part-string.html)

Dan Thompson

How do you include a quotation as part of a string ??
 
I am trying to run this line of code which obviously doesn't work.

MyString = " " " + "Hello" + " " "
debug.print MyString

what I am trying to end up with is

"Hello" as my string QUOTES INCLUDED as part of the string.
however every time I try to use them as part of a string VBA thinks that Im
using them as a qualifer.

Can anyone help me out with this one ?

Thanks, Dan Thompson

Niek Otten

How do you include a quotation as part of a string ??
 
For a quote between quotes, use two quotes, like in
?" "" " + "Hello" + " "" "

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"Dan Thompson" wrote in message ...
|I am trying to run this line of code which obviously doesn't work.
|
| MyString = " " " + "Hello" + " " "
| debug.print MyString
|
| what I am trying to end up with is
|
| "Hello" as my string QUOTES INCLUDED as part of the string.
| however every time I try to use them as part of a string VBA thinks that Im
| using them as a qualifer.
|
| Can anyone help me out with this one ?
|
| Thanks, Dan Thompson



jk

How do you include a quotation as part of a string ??
 
Dan,

You can also create a variable to equal a double quote. For example,

str_dblquote = chr(34)

where chr(34) is a double quote.

then try

str_dblquote + "Hello" + str_dblquote

which will print "Hello"

Good luck!

"Niek Otten" wrote:

For a quote between quotes, use two quotes, like in
?" "" " + "Hello" + " "" "

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"Dan Thompson" wrote in message ...
|I am trying to run this line of code which obviously doesn't work.
|
| MyString = " " " + "Hello" + " " "
| debug.print MyString
|
| what I am trying to end up with is
|
| "Hello" as my string QUOTES INCLUDED as part of the string.
| however every time I try to use them as part of a string VBA thinks that Im
| using them as a qualifer.
|
| Can anyone help me out with this one ?
|
| Thanks, Dan Thompson





All times are GMT +1. The time now is 06:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com