|
-
Apr 8th, 2005, 08:23 AM
#1
Thread Starter
Frenzied Member
equivalent of #defines in VB
Hi
what is the equivalent of a #define preprocessor parameter in VB.
i have got this factor spread across my VB project and i was wondering if there was some way i could just change it in one place. and voila!! it changes globally
-
Apr 8th, 2005, 09:16 AM
#2
Re: equivalent of #defines in VB
er... make a module, put:
Code:
Public dblPreprocessorFactor as double
Perhaps similar to this?
(I have a feeling that this is too easy )
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Apr 11th, 2005, 05:03 AM
#3
Thread Starter
Frenzied Member
Re: equivalent of #defines in VB
if i were to assign some value to this statement globally then how would i do it
-
Apr 11th, 2005, 06:03 AM
#4
Addicted Member
Re: equivalent of #defines in VB
If you put the following in a module
VB Code:
Public dblPreprocessorFactor as double
you can reference it from anywhere in your project.
VB Code:
dblPreprocessorFactor = 0.5
if you fail to plan, you plan to fail
-
Apr 11th, 2005, 06:06 AM
#5
Re: equivalent of #defines in VB
Code:
dblPreprocessorFactor=44
If it is in a module and declared public - you can change it from anywhere in the app.
If its private, only in that module can it be changed.
For more infor - search or read the help files for Variables and Scope.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Apr 12th, 2005, 05:59 AM
#6
Thread Starter
Frenzied Member
Re: equivalent of #defines in VB
ah i understand what you mean,
i declare all my globals in a module, set them to values, and i am good to go
-
Apr 14th, 2005, 04:21 AM
#7
Thread Starter
Frenzied Member
Re: equivalent of #defines in VB
i need to add them in a module not a form, correct?
are there any pitfalls i need to watch out for when programming a module? i mean in what ways does a module differ from a form?
-
Apr 14th, 2005, 04:37 AM
#8
Addicted Member
Re: equivalent of #defines in VB
a form and module code are the same.
as the code for a form is held within the forms module. (you can turn 'Has Module' on or off)
the stand alone module can be coded the same way, but usually contains functions, and public subs, where a forms module contains private subs.
if you are using Global variables you need to ensure you initialise them when you are using them for different functions/features of your code.
modules are very good for holding repetitive pieces of code.
I use them a lot to carry out selects for report/form opening and pass the variables to the module. similarly for SQL statements, passing variables from the form to the global code.
HTH
if you fail to plan, you plan to fail
-
Apr 14th, 2005, 07:40 AM
#9
Thread Starter
Frenzied Member
Re: equivalent of #defines in VB
is the best way to declare and initialise the global variable in a function say myFunction present in the module and then in the startup module/form cal the fuction myFunction?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|