How to access global variable EXPLICITLY

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
 
S

Steve Schapel

Vikram,

Change the name of one of the variables. You should never name a
variable the same as the name of a global variable.
 
V

vikram.singh

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
 
S

Steve Schapel

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top