Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Quote constant?
Hi,
I would like to make a vbQuote constant, like: Const vbQuote As String = Chr(34) ....so that I can use vbQuote when I need to insert a " in a string, instead of Chr(34). But when I do the above code line to define the constant, I get an error saying that a constant expression is needed. But, in my eyes that is a constant expression??? So, how do I make a vbQuote constants? Thanks, CE |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Quote constant?
In message of Sat, 13
Apr 2013 09:22:32 in microsoft.public.excel.programming, Charlotte E. writes Hi, I would like to make a vbQuote constant, like: Const vbQuote As String = Chr(34) ...so that I can use vbQuote when I need to insert a " in a string, instead of Chr(34). But when I do the above code line to define the constant, I get an error saying that a constant expression is needed. But, in my eyes that is a constant expression??? It may produce a fixed result, but that result is not, technically, a constant. So, how do I make a vbQuote constants? Thanks, CE This: vbQuote = ["] is the result of running foo: Option Explicit Const vbQuote As String = """" Public Sub foo() Debug.Print "vbQuote = [" & vbQuote & "]" End Sub -- Walter Briscoe |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Quote constant?
I'd set this up as a global variable...
Public vbQuote$ ...and initialize its value in my InitGlobals procedure at startup... vbQuote = Chr(34) ...so in the Immediate Window, typing... ?vbquote ...returns " -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Quote constant?
I like this one :-)
Both makes the variable global, but also opens up for temporary use of the variable for other purposes - as long as you remember to set it back :-) Thanks, CE Den 13.04.2013 20:18, GS skrev: I'd set this up as a global variable... Public vbQuote$ ...and initialize its value in my InitGlobals procedure at startup... vbQuote = Chr(34) ...so in the Immediate Window, typing... ?vbquote ...returns " |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Quote constant?
You're welcome!
-- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Quote constant?
Charlotte E. wrote:
Den 13.04.2013 20:18, GS skrev: I'd set this up as a global variable... Public vbQuote$ ...and initialize its value in my InitGlobals procedure at startup... vbQuote = Chr(34) ...so in the Immediate Window, typing... ?vbquote ...returns " I like this one :-) Both makes the variable global, but also opens up for temporary use of the variable for other purposes - as long as you remember to set it back :-) But that defeats the whole purpose of using constants. Walter's version... Const vbQuote As String = """" ....is what I would use. -- Oh, I know a guy with a car named Sue He was the butt of many jokes He had named his car after his wife 'Cause it's hard to start and it smokes. |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Quote constant?
But that defeats the whole purpose of using constants. Walter's
version... Const vbQuote As String = """" I agree! My reply was only to suggest a way to use Chr(34), which she stated she wanted some way to do that. Personally, I'd just use the keyboard in most cases, but I do see a value in storing this in a variable/constant when passing double quotes as an arg or when filtering... -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Quote constant?
On Sat, 13 Apr 2013 16:41:32 -0400, GS wrote:
But that defeats the whole purpose of using constants. Walter's version... Const vbQuote As String = """" I agree! My reply was only to suggest a way to use Chr(34), which she stated she wanted some way to do that. Personally, I'd just use the keyboard in most cases, but I do see a value in storing this in a variable/constant when passing double quotes as an arg or when filtering... Could it have to do with touch screen interface considerations? |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Quote constant?
On Sat, 13 Apr 2013 16:41:32 -0400, GS wrote:
But that defeats the whole purpose of using constants. Walter's version... Const vbQuote As String = """" I agree! My reply was only to suggest a way to use Chr(34), which she stated she wanted some way to do that. Personally, I'd just use the keyboard in most cases, but I do see a value in storing this in a variable/constant when passing double quotes as an arg or when filtering... Could it have to do with touch screen interface considerations? Doubtful!<g Which is easier typing... """" ...to get " OR vbQuote ...when string building needs internal quotes within the string? -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Quote Ammendments | Excel Discussion (Misc queries) | |||
Constant loan payments vs. constant payments of principal | Excel Worksheet Functions | |||
We are looking for a quote log. | Excel Discussion (Misc queries) | |||
Typing a quote character Vs pasting a quote character= what happens to the resulting CSV? Interesting!! | Excel Programming | |||
Typing a quote character Vs pasting a quote character= whathappens to the resulting CSV? Interesting!! | Excel Programming |