Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Simple Constant Question


Message #1 by "Chad Silva" <csilva@f...> on Mon, 12 Nov 2001 14:57:17
Are you by any chance thinking of conditional compilation constants?

The statement:
  #Const DEBUG_ME = -1

defines a conditional compilation constant that's resolved at compile time &
can be used in #If ...#EndIf blocks to affect what gets compiled into your
.exe.  These never make it to code that runs on your users' machines.

But the statement:
   Const boocDebugMe as Boolean = True

defines a programmatic constant which is (I believe) allocated on the stack
at runtime every time your program is run.

HTH,

-Roy

Roy Pardee
Programmer/Analyst
SWFPAC Lockheed Martin IT
Extension 8487

-----Original Message-----
From: Chad Silva [mailto:csilva@f...]
Sent: Monday, November 12, 2001 6:57 AM
To: professional vb
Subject: [pro_vb] Simple Constant Question



This is a seemingly simple question about Constants in VB that I can't 
seem to find any confirming documentation for(and am not really sure how i 
could confirm this myself).  If I declare a constant:

Const cMyConst as String = "This is" & " " & "a concatenated constant 
string"

One would think that this would be concatenated at compile time as 
it's "constant" so no need to put off the concatenation til runtime.  
However, I've seen documentation that suggests otherwise (vb docs, in 
avoiding circular constant references, says it'll bug out at runtime).

Can anyone confirm whether constants are compiled or just concatenated at 
runtime?

Thanks
Chad

  Return to Index