Using Global Class Objects

Using Global Class Objects

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 Property
In 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?

You can instantiate the class in the MDI form like so:

Dim objClass as New CClass
But 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.

See also  Essential Measures for Safeguarding Your Digital Data

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist