473,320 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

quick question ---- global variables

Hi

I wanted to create a variable that can be used as a flag throughout my application
Can anyone tell me how i can create this global varible. Im confused as to how these work I tried...

Public Shared MyVariable as Boolea

and i tried to us

Friend Shared myVariable as Boolea

I wrote these in form1 and then i tried accessing the variable in form2, however i got a message stating the varibale has not been declared. Can anyone please explain to me what im doin wrong??
Many thx
Jul 21 '05 #1
3 1131
Hi,

Place it in a module instead of a form.

Module Module1

Public MyVariable as Boolean

End Module
Ken
----------------
"varun" <an*******@discussions.microsoft.com> wrote in message
news:82**********************************@microsof t.com...
Hi,

I wanted to create a variable that can be used as a flag throughout my
application.
Can anyone tell me how i can create this global varible. Im confused as to
how these work I tried....

Public Shared MyVariable as Boolean

and i tried to use

Friend Shared myVariable as Boolean

I wrote these in form1 and then i tried accessing the variable in form2,
however i got a message stating the varibale has not been declared. Can
anyone please explain to me what im doin wrong???
Many thx

Jul 21 '05 #2
Thx Ken

May i ask what the module is used for
Is it a store for all the globle variables and procuedures?
Jul 21 '05 #3
varun <an*******@discussions.microsoft.com> wrote:
I wanted to create a variable that can be used as a flag throughout my application.
Can anyone tell me how i can create this global varible. Im confused
as to how these work I tried....

Public Shared MyVariable as Boolean

and i tried to use

Friend Shared myVariable as Boolean

I wrote these in form1 and then i tried accessing the variable in
form2, however i got a message stating the varibale has not been
declared. Can anyone please explain to me what im doin wrong???


Well, you haven't shown how you tried to access the variable. You need
to tell VB.NET which class it's in, eg

Form1.MyVariable

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.