Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting quotation marks into a constant 1

Status
Not open for further replies.

Sashanan

Programmer
Jan 19, 2001
235
NL
One of the routines in my VB6 application opens an Excel worksheet, and fills it with some data from SQL Server. In a recent addition, it sets the data format for one of the columns to financial data formatted as Dutch euros. The command for this is, in my case:

xlsApp.Cells(row, 5).NumberFormat = "_-[$€-413] * #,##0.00_-;_-[$€-413] * #,##0.00-;_-[$€-413] * " & Chr(34) & "-" & Chr(34) & "??_-;_-@_-"

Obviously the string for this particular format is rather complicated so I figured I'd put it into a constant named XlsDutchEuroFormat, but then I found out that I can't do function calls in a constant, disallowing my Chr(34) workaround to putting quotation marks in it.

Is there some other way I can put this into a constant? The quotation marks are an essential part of the string, I'm afraid. My code works fine without making it into a constant but if at all possible, I'd like to use one here.


"Much that I bound, I could not free. Much that I freed returned to me."
(Lee Wilson Dodd)
 

try...
[tt]
YourVariable = """"
'or
XlsDutchEuroFormat = "_-[$€-413] * #,##0.00_-;_-[$€-413] * #,##0.00-;_-[$€-413] * " & """" & "-" & """" & "??_-;_-@_-"
[/tt]

Yes that is 4 " in a row...

Good Luck

 
Works fine, thanks for the swift reply! Just now teaching myself to make use of constants to make my code more readable, and I just couldn't stand not being able to do it in such an obvious spot. :)


"Much that I bound, I could not free. Much that I freed returned to me."
(Lee Wilson Dodd)
 
In such cases, what I do is just declare the variable and name them as if they were constants (for prog docu purposes). For constants, I always type them on upper case.

Just a suggestion, though. At least, I can append function-generated strings, such as of Chr(). [peace]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top