Escape sequence

  • Thread starter Thread starter Louis
  • Start date Start date
L

Louis

Hi

I am executing a statement in vba to insert a record into a MySQL database.

MySQL sees ' and " as special characters. So i have included a function to
check for these and include an appropriate \ to escape them.

Then it occurred to me that because these characters are in a string - vba
might also recognise them as functional and not textual - so i need to
escape them in vba too. How can i escape them in both? Does vba use the \ as
its escape?

Thanks

Lou
 
VBA wants you to Double up on the character to escape it. So for example if
you wanted to assign a literal string 37" HD TV to a VBA variable strItem
you'd code it like this. strItem = "37"" HD TV"

Ron W
 
Hi Lou,

VBA doesn't use \ as an escape character. But if you want to include "
in a string literal you have to escape it with itself (i.e. double it).
So to put
\"
in a VBA string literal you'd use
"\"""
as against the C-ish
"\\\""
 
Back
Top