Re: global variables
- From: fajp@xxxxxxxxxxxxxxxxxxxx (Frank Adam)
- Date: Mon, 13 Feb 2006 08:56:14 +1100
On Sun, 12 Feb 2006 19:32:17 -0000, "james" <ds@xxxxxxxxxxx> wrote:
Hi People,You can define the Type as Public in a standard bas module, then just
Sorry, I'm a bit of a newbie and was wondering, if I have a program with a
lot of forms, which most have the same global variables such as:
Private Type OnePair
PairID As Integer
P1ID As Integer
P1Name As String * 30
P2ID As Integer
P2Name As String * 30
Score As Integer
Legible As Boolean
End Type
Dim Pair As OnePair
Dim NumberOfPairs As Integer
Dim Filename As String
Is there a way of shortening the code so that I don't need to add the above
code in every single form??
declare the variables on the form level.
I say this way, because the above doesn't make sense as "global",
since you are declaring 'Pair' etc.. as private variables for each
Form. Note that Dim creates a private var. So if you have it working
fine like that, they are not globals, but Form level variables.
If each form has it's own unique Pair variable, then you need to
declare those at the form level to restrict scope to each Form.
If on the other hand, Pair should be accessible from all forms, then
you can declare it Public in the bas module as well and that will make
it "global". Just remember that with this latter one, if Form2 changes
Pair, Form1 will see that change too.
--
Regards, Frank
.
- Follow-Ups:
- Re: global variables
- From: G Doucet
- Re: global variables
- References:
- global variables
- From: james
- global variables
- Prev by Date: Re: global variables
- Next by Date: Re: how do you terminate an application?
- Previous by thread: Re: global variables
- Next by thread: Re: global variables
- Index(es):
Relevant Pages
|
Loading