dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
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
Oct 1, 1996

WEBINAR:

On-Demand

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


Accessing Properties

Question:
How do you access a Public Property in a class module from an in-project module? For example: In a new project create one class module; "Class1" and one bas module; "Module1", with the following code: Class1:
Public Property Get Test() As Integer
    Test = 99
End Property
Module1:
Public Sub Main()
    Debug.Print {Class1.Test}  ' This is where we want to 
                               ' get the info from Class1
End Sub
What is necessary to retrieve the property value from Class1 within other parts of the application??????

Answer:
You've basically got it, except you need to instantiate (create) an object of class "Class1". Do that like this:

Dim aClass1 as Class1
Set aClass1 = New Class1
Then you can print Test with:
Debug.Print aClass1.Test
DevX Pro
 
Comment and Contribute

 

 

 

 

 


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

 

 

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