Question:
I have a general class that has the following amongst other stuff.
Public Property Get Status() As String Status = stattxtEnd PropertyPublic Property Let Status(vNewValue As String) stattxt = vNewValueEnd PropertyIn the Mdi document I create a new instance of the class that this code is in I then have a timer event on the Mdi that monitors this value. I set the value to this property in child forms, but because I have to declare a new instance of the class in the child form my mdi document does not pick it up. How can I set the value in the child document without creating a new instance of the class object?
Answer:
You can instantiate the class in the MDI form like so:
Dim objClass as New CClassBut declare the objClass variable in a separate code module. Any variablesdeclared within a form, even if they are in the declarations section, arelocal to that form. You can’t share them across forms automatically. Theonly way to make it work is to put the variable declaration in a code module.