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
Oct 1, 1996



Application Security Testing: An Integral Part of DevOps

Accessing Properties

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

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.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date