Global constants - such a thing?

C

Chuck

Hi all

I'd like to declare some constant values for use across a number of modules.
Do I declare them as "global" or "public"? eg:

Global Const BOILERPLATE_PATH as String = "X:\MyPath"

vs

Public Const BOILERPLATE_PATH as STring = "X:\MyPath"

I'd like to declare them only once. I've tried creating a separate module
called modGlobalConst and putting all my constants there but some subs in
other modules don't seem to be picking up those values.

I've seen "Global Const" used in MS sample code but there doesn't seem to be
any help file or KnowledgeBase info on the term.

Or am I going about this wrong?

Thanks for any feedback

Chuck
 
S

Steve Lang

Hi Chuck,

Use public const and make sure any projects that you want to use the public
values has the project containing the declarations as a reference. Even
doing that, I have noticed that sometimes word "loses" a publicly declared
value. To work around it, I have no public constants per se, I save the
values in an external ini file, then assign them to public variables during
the application's startup.

Since it drops public variables periodically, (at least it did in version
2000), I periodically test for the value's existence. If it is missing, I
call the function that loads the values during startup.

HTH and have a great day!

Steve
 
C

Chuck

Thanks for the tip!

Steve Lang said:
Hi Chuck,

Use public const and make sure any projects that you want to use the public
values has the project containing the declarations as a reference. Even
doing that, I have noticed that sometimes word "loses" a publicly declared
value. To work around it, I have no public constants per se, I save the
values in an external ini file, then assign them to public variables during
the application's startup.

Since it drops public variables periodically, (at least it did in version
2000), I periodically test for the value's existence. If it is missing, I
call the function that loads the values during startup.

HTH and have a great day!

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top