Click to See Complete Forum and Search --> : passing Reference of an instance of a class


bcoyote
April 11th, 2001, 03:11 PM
I have built a class and instantiated it on my Main Form. I want every other Form to use this same instance of the class. How can I pass the instance reference to other forms.

thanks in advance,
bcoyote

forty7
April 11th, 2001, 03:40 PM
There are a couple of choices here:
One is to add a standard module to the project and declare the variable as public, but initialize it in your main form. You'd be able to access it in all forms of the project.
Another would be to add it as a public variable of the main form and let the other forms access it throught the main form (e.g. frmMain.myClassInstance).
I'm sure these aren't the only alternatives, but they will work.

thanx/good luck,
adam