variable with commas and quotes

  • Thread starter Thread starter Barrett Bonden
  • Start date Start date
B

Barrett Bonden

how to create a variable with embedded commas and quotes ?
when I try something like t1= " "test", "test" " it blows up ....
 
Try

t1 = " ""test"", ""test"" "
Debug.Print t1

Since quotes are the delimiter, when VBA sees the next quote it thinks it is
the next delimiter. If you double them up, it knows to treat them as a
literal quote to be inserted into the string. The result from above would
be:

"test", "test"

Of course, the leading and trailing spaces are hard to see here.
 
Or
t1 = chr(34) & "test" & chr(34)

Wayne Morgan said:
Try

t1 = " ""test"", ""test"" "
Debug.Print t1

Since quotes are the delimiter, when VBA sees the next quote it thinks it is
the next delimiter. If you double them up, it knows to treat them as a
literal quote to be inserted into the string. The result from above would
be:

"test", "test"

Of course, the leading and trailing spaces are hard to see here.
 
Back
Top