Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 279
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 277
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Quote Ammendments Dude3966 Excel Discussion (Misc queries) 1 March 4th 08 05:31 PM
Constant loan payments vs. constant payments of principal lalli945 Excel Worksheet Functions 3 December 20th 06 10:33 PM
We are looking for a quote log. Mitch Excel Discussion (Misc queries) 5 April 30th 05 05:22 AM
Typing a quote character Vs pasting a quote character= what happens to the resulting CSV? Interesting!! Tom Ogilvy Excel Programming 0 August 3rd 03 02:53 AM
Typing a quote character Vs pasting a quote character= whathappens to the resulting CSV? Interesting!! Jon Peltier[_3_] Excel Programming 0 August 3rd 03 02:22 AM


All times are GMT +1. The time now is 09:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"