Salvete! I want to create a new instance of a class when I click on a button, but I need to interact with members of that class using other controls on the form, so I need the class to have a global scope. I know I could call the new class in formload, but the class creates certain variables that need to be current. If it is done on formload, the variables wouldn’t be current, because if the class is created at formload, it would have different info at that time. Surely, there must be a way to create an instance of the myClass from within a sub that is accessible from other subs of the same class.
Something like this:
click on myForm.button1 to dim myclassInstance as new myClass
then, click on myForm.button2, to make mylabel.text = myClassiInstance.myvariable
First, you may be having problems because MyClass is a reserved keyword, so if you are trying to create a class with this name, you will need to choose a different class name.
Having said that, I believe that what you want is something similar to the following, where we store the instance of the class as a private member of the form. This instance will only “live” as long as the form exists, so if it needs to be share among forms, then you will need to move the instance to a different location (a global variable or a shared member).