![]() |
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 |
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 |
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 |
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 " |
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 |
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. |
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 |
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? |
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 |
All times are GMT +1. The time now is 07:04 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com