954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Issue Sharing variables across two forms: VB Express 2008

I have three separate forms.
Form1, Form2, and Form3

I declared Public var1 as Integer within Form1.
Form2 and Form3 can see/access var1 as Form1.var1

However,
when I declare Public var2 as Integer within Form2 (when it opens), Form3 (when opened) cannot access var2 whatsoever.

Don't know what I'm missing. Perhaps a fundamental rule for declaring/using Public variables???

Help is appreciated.

Thanks.

EdVBDev
Newbie Poster
1 post since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

In visual basic 6.0, of which you have posted your question in the wrong forum, public form variables are access via form1.variablename

Good Luck

vb5prgrmr
Posting Virtuoso
1,912 posts since Mar 2009
Reputation Points: 156
Solved Threads: 296
 

I have three separate forms. Form1, Form2, and Form3

I declared Public var1 as Integer within Form1. Form2 and Form3 can see/access var1 as Form1.var1

However, when I declare Public var2 as Integer within Form2 (when it opens), Form3 (when opened) cannot access var2 whatsoever.

Don't know what I'm missing. Perhaps a fundamental rule for declaring/using Public variables???

Help is appreciated.

Thanks.

Just create a Module and declare all your Public variables there.
you can access all those variables anywhere in your program

c0deFr3aK
Junior Poster in Training
71 posts since Mar 2009
Reputation Points: 11
Solved Threads: 10
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You