Re: question on scope of a variable

From: Word Heretic (myfullname_at_tpg.com.au)
Date: 12/16/04


Date: Thu, 16 Dec 2004 15:19:44 +1100

G'day "Chip Orange" <Chip.Orange@psc.state.fl.us>,

Accessible everywhere is not Static.

If I have a std code module and declare at the top of it, outside of
any sub

Public ICanSeeThisEverywhere as Variant

then that should be accessible to your form.

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice

Chip Orange reckoned:

>I've tried declaring a public variable in a module of my project in hope
>that it can be accessible by any of the forms; I mean that I'd like a form
>to be able to initialize it, or have access to it's value if it's
>initialized by a routine in the modules section.
>
>While this compiles for me, I'm getting a runtime error that indicates the
>object variable isn't initialized when accessed by a form, but declared and
>initialized by a module.
>
>If I add a second initialization statement in the form itself then all runs
>ok.
>
>I obviously don't understand the scoping rules here, so could someone
>explain to me if it's possible to have a variable accessible everywhere
>(that is, have it be static?).
>
>I did try declaring it using the STATIC command in the module but the
>compiler wouldn't allow that.
>
>thanks.
>
>Chip
>
>



Relevant Pages

  • Re: Setting pointer to null!
    ... I think this debugging fetaure emerged originally ... developer forgets to initialize a variable and it accidentally ... to declare a bunch that would be "initialized" in relatively distant code. ... because you prevent the compiler from initializing them ...
    (microsoft.public.vc.language)
  • Re: Replicating results
    ... gradient calculation used in a large optimization routine. ... It will make sure that if you do something like declare a variable called "x1" and use a variable called "xl" the compiler will tell you that xl was undeclared. ... Make sure that you initialize all of your variables, ...
    (comp.lang.fortran)
  • Re: "no variable or argument declarations are necessary."
    ... the compilor will allert you ... If I forget to declare several variables in C, ... >> forget to initialize several variables in Python, ... > runtime error per "forgot to initialize". ...
    (comp.lang.python)
  • Re: [Eclipse] How to fix indentations.
    ... Why do you declare the list static but initialize it in the ... the method that picks and displays the random fortune, ... The variable should be of the interface type, ...
    (comp.lang.java.help)