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


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Oct 1, 1996

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