How to access global variable EXPLICITLY

  • Thread starter Thread starter vikram.singh
  • Start date Start date
V

vikram.singh

Hi,
i have declared one global varibale named VAR1 in form module and
another defined in sub proecdure with the same name (VAR1) in the same
form module . if i use VAR1 then local variable will be
accessed .......but if i wanna use the global variable explicitely in
the same procedure then how can i do that.

Vikram
 
Vikram,

Change the name of one of the variables. You should never name a
variable the same as the name of a global variable.
 
Hi Steve,
Thanks for your reply.

I have also done the same thing but just for my knowledge, wanted to
know as in c++ and in java we can access global variable explicitely
so similarly I was hoping that we also can do it here. But i was
unable to find a solution and posted a query for your kind
consideration. So basically wat i wanted to know for my knowledge
that vba doesnt support this or do do we have to do something else
rather than defining with different name.

B' Regards,
Vikram Singh
 
Vikram,

I am not 100% sure of the answer to your question. But as far as I
know, it is not possible. I suppose that to me, it is a very unusual
question - I can't imagine a scenario where one would want to name a
module scope variable the same as the name of a global variable. So I
have never seen this topic considered.

You have posted to a macros newsgroup, which is really unrelated to VBA
and to the concern you have raised. If you would like to re-post your
question to a code-related newsgroup, for example to
microsoft.public.access.modulesdaovba, you may find someone there with
more experience of this matter.
 
Back
Top