| | |
Escape Sequences or Accepting Double Quotes in String Constants
Thread Solved
![]() |
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:
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:
So does anyone know the code to accept double quotes in string constants?
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)
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?
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:
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/
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
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/
![]() |
Similar Threads
- Odd string concatenation behavior? (Perl)
- how to code single/double quotes inside the quotes. (PHP)
- Restoring a Registry Setting thru VBS (Windows NT / 2000 / XP)
- ANSI string problem (C++)
- Looking for _gcvt(double,int,string) (C++)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Command Line Interface
- Next Thread: Help in creating a link table in MS-Access dynamically using VB 6.0
| Thread Tools | Search this Thread |
* 6 2007 access activex add age basic birth bmp calculator cd cells.find click client code connection connectionproblemusingvb6usingoledb creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit excel excelmacro file filename form header iamthwee image inboxinvb internetfiledownload listbox listview liveperson login looping microsoft movingranges objectinsert open oracle password program prompt range-objects readfile reading remotesqlserverdatabase report save search sendbyte sites sql sql2008 sqlserver subroutine tags time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web windows






