943,537 Members | Top Members by Rank

Ad:
Dec 8th, 2005
0

Escape Sequences or Accepting Double Quotes in String Constants

Expand Post »
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?
Similar Threads
Reputation Points: 15
Solved Threads: 2
Newbie Poster
SlyMaelstrom is offline Offline
21 posts
since Oct 2005
Dec 8th, 2005
0

Re: Escape Sequences or Accepting Double Quotes in String Constants

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/
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Dec 8th, 2005
0

Re: Escape Sequences or Accepting Double Quotes in String Constants

Yep, that makes sense. Thank you.
Reputation Points: 15
Solved Threads: 2
Newbie Poster
SlyMaelstrom is offline Offline
21 posts
since Oct 2005
Oct 27th, 2006
0

Re: Escape Sequences or Accepting Double Quotes in String Constants

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.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Ganesh_Kutty is offline Offline
1 posts
since Oct 2006
Oct 27th, 2006
1

Re: Escape Sequences or Accepting Double Quotes in String Constants

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.
Reputation Points: 15
Solved Threads: 2
Newbie Poster
SlyMaelstrom is offline Offline
21 posts
since Oct 2005
Sep 20th, 2008
0

Re: Escape Sequences or Accepting Double Quotes in String Constants

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 />
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ShaunRigby is offline Offline
1 posts
since Sep 2008
Mar 22nd, 2011
0
Re: Escape Sequences or Accepting Double Quotes in String Constants
Hey use double times double quote for any escape sequence character like

[foo].ControlSource = "=IIf([foo]>0, 100*([foo1]/[foo2]) & ""%"", ""%"")"
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kiran2010 is offline Offline
2 posts
since Mar 2011

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Combobox and Masktextbox in Visual Basic
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: help me please. lock the task manager, taskbar & the button to open the task manager





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC