Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Visual Basic
Expertise: Beginner
Jul 24, 1997



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Using Global Class Objects

I have a general class that has the following amongst other stuff.
Public Property Get Status() As String
    Status = stattxt
End Property

Public Property Let Status(vNewValue As String)
    stattxt = vNewValue
End 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 variables declared within a form, even if they are in the declarations section, are local to that form. You can't share them across forms automatically. The only way to make it work is to put the variable declaration in a code module.
DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date