Escape Sequences or Accepting Double Quotes in String Constants

Thread Solved

Join Date: Oct 2005
Posts: 21
Reputation: SlyMaelstrom is an unknown quantity at this point 
Solved Threads: 2
SlyMaelstrom's Avatar
SlyMaelstrom SlyMaelstrom is offline Offline
Newbie Poster

Escape Sequences or Accepting Double Quotes in String Constants

 
0
  #1
Dec 8th, 2005
Hi, I'm doing some work for an Access Database but I caught a snag writing an event. I want the event to (among other things) change the Control Source of an object. This is no problem, except I have to set the control source as a string, and the string being an Immediate if function contains a string in it.

Now in C and C++, to write double quotes in a literal constant you just use a backslash infront of it to take it as it is. Such as:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. str1 = "President Lincoln said \"Four score and seven years ago...\""

I tried this in my VBA statement and no such luck. It just took the backslash in a string and closed the string at the quotes, like so:

[foo].ControlSource = "=IIf([foo]>0, 100*([foo1]/[foo2]) & \"%\", \"%\")"

So does anyone know the code to accept double quotes in string constants?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Escape Sequences or Accepting Double Quotes in String Constants

 
0
  #2
Dec 8th, 2005
I will say that the C/C++/Javaish/Perlish/etc/etc structure for working with escape sequences is a real treat compared to The basic language. The only way to do this, is to concantenate the character code value to the string where the double quote would be. It's sick, and it makes the code a lot less understandable when dealing with strings, but here is how your example would look:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. str1 = "President Lincoln said " & chr(34) & "Four score and seven years ago..." & chr(34)

chr is the basic function to return the ascii value of a given character code. In this case, 34, which is ". This page has a cool list of them: http://www.lookuptables.com/
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 21
Reputation: SlyMaelstrom is an unknown quantity at this point 
Solved Threads: 2
SlyMaelstrom's Avatar
SlyMaelstrom SlyMaelstrom is offline Offline
Newbie Poster

Re: Escape Sequences or Accepting Double Quotes in String Constants

 
0
  #3
Dec 8th, 2005
Yep, that makes sense. Thank you.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 1
Reputation: Ganesh_Kutty is an unknown quantity at this point 
Solved Threads: 1
Ganesh_Kutty Ganesh_Kutty is offline Offline
Newbie Poster

Re: Escape Sequences or Accepting Double Quotes in String Constants

 
0
  #4
Oct 27th, 2006
But when i use Chr(34) it replaces a smart curly (“) double quote but i need to replace it with a straight double quote (") which. Is there a solution for this.
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 21
Reputation: SlyMaelstrom is an unknown quantity at this point 
Solved Threads: 2
SlyMaelstrom's Avatar
SlyMaelstrom SlyMaelstrom is offline Offline
Newbie Poster

Re: Escape Sequences or Accepting Double Quotes in String Constants

 
1
  #5
Oct 27th, 2006
Wow... here is another reason why bumping posts suck... I get a stupid email from a thread I subscribed to almost a year ago. Thanks for the spam, Ganesh.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 1
Reputation: ShaunRigby is an unknown quantity at this point 
Solved Threads: 0
ShaunRigby ShaunRigby is offline Offline
Newbie Poster

Re: Escape Sequences or Accepting Double Quotes in String Constants

 
0
  #6
Sep 20th, 2008
Originally Posted by SlyMaelstrom View Post
Wow... here is another reason why bumping posts suck... I get a stupid email from a thread I subscribed to almost a year ago. Thanks for the spam, Ganesh.
<bump />
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC