Static Variable

I have a variable declared publicly in a module as: "PUBLIC FlagToStop as boolean" because it used thoughout my project in almost every form.

However, when I set this as "FlagToStop=True" in one form, the value of the variable doesn't carry over to other forms. I know there must be a way to do this. Maybe something with the "Static" keyword, but I tried that in the VB example, but it didn't seem to make a difference.. Any ideas?

LVL 2
cantrellAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mark2150Commented:
If you have a local declaration of the SAME NAME it will override the global. Betcha you've got a duplicate of the definition. Probably this is the original form that the var was copied from.

M
0
vettrangerCommented:
define this variable in a module as

Global FlagToStop as boolean

It will then be available in every form with no further effort.

As mark2150 says, make sure you don't have it defined anywhere else, as the closest level definition will take precedence.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cantrellAuthor Commented:
mark2150 - nope. Declared only once as public in only one module.

vettranger - the "GLOBAL" didn't make any difference than the 'PUBLIC' did. And, for some reason, "GLOBAL" isn't even listed in the vb5 help... Go figure. However, for your effort I'll give you the points.

It was a problem with me re-setting the flag in a place I shouldn't have.

0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

cantrellAuthor Commented:
mark2150 - nope. Declared only once as public in only one module.

vettranger - the "GLOBAL" didn't make any difference than the 'PUBLIC' did. And, for some reason, "GLOBAL" isn't even listed in the vb5 help... Go figure. However, for your effort I'll give you the points.

It was a problem with me re-setting the flag in a place I shouldn't have.

0
cantrellAuthor Commented:
sorry vettranger, post something - anything and i'll give you the points. I clicked the wrong button and can't give you the points until you respond again.
0
mark2150Commented:
Set a breakpoint on the variable's value being changed.

Research the entire project to find *ALL* references to that var name. Sure as god made little green apples there's another declaration somewhere.

M
0
mark2150Commented:
Sure you can. use the "Grade Comment as Answer" feature...

M
0
cantrellAuthor Commented:
sorry vettranger, post something - anything and i'll give you the points. I clicked the wrong button and can't give you the points until you respond again.
0
mark2150Commented:
See how nice that worked! :-) Is way cool feature!

M
0
cantrellAuthor Commented:
Thanks mark2150 - you've been most helpful in all of my questions.
0
vettrangerCommented:
Its obviously common for something like that to happen also! LOL

In any case, both Mark2150's comment and mine should serve you in the future. However, it is advisable to use both public and global variables judiciously, just for this reason.
0
cantrellAuthor Commented:
Thanks mark2150 - you've been most helpful in all of my questions.
0
mark2150Commented:
Vett,

I haven't noticed *ANY* difference between GLOBAL's and PUBLIC's. I've got legacy programs that were coded in VB4 that used GLOBAL's exclusively. My code always uses PUBLIC's. Have some that are mixed. Never noticed *ANY* differences between the two. Have you?

M
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.