Groups | Blog | Home
all groups > dotnet academic > july 2003 >

dotnet academic : share variables between forms?


Joe Alan Mackey
7/18/2003 8:11:52 AM
I have a MDI project. Multiple pages which are not parent child forms.
I want to use a variable I set on form1 on form2, in VB6 I would do
this. "MyText.text = Form2.TextBox1.Text" But that does not work for me.
I have also tried : :Form2.textBox1.text = Me.MyText.Text". The variable
is set to Friend.
Any suggestions or reading assignments?
TIA

Joe Alan Mackey
Peter van der Goes
7/18/2003 9:57:58 AM

[quoted text, click to view]
You can add a module to your project and declare the variables that need to
be shared between form as Public in the module. That works for me. All forms
should then have access to a variable so declared.

Eddy
7/20/2003 3:08:40 PM
Declare variables in a module, it's a way share variabeles. But somethings
in me says it is not the best way. When you have to share a huge quantity of
variables, you are going to fight a war to keep it orderly.
To me sharing variabeles should:
- parse as a parameter to the form or class of your choice.
- set by a property in your form or class.
The advantage is that the variable is stored, where you need it. When you
close your form, you have to retrieve the results before you destroy your
object
I think it is a better way.

Or in your case you can't access TextBox1 on Form2 because it's modifier is
set to private, make it public and you can do it like in VB6.

Let me know what you think !!!


[quoted text, click to view]

Peter van der Goes
7/22/2003 9:04:48 AM

[quoted text, click to view]
To each his own, Eddy.
I was offering a basic way around a problem to the OP, who indicated that
he's new to the environment. Your alternative is certainly more
sophisticated.


--
Peter - [MVP - Academic]

AddThis Social Bookmark Button