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 = 99End PropertyModule1:
Public Sub Main() Debug.Print {Class1.Test} ‘ This is where we want to ‘ get the info from Class1End SubWhat 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 Class1Set aClass1 = New Class1Then you can print Test with:
Debug.Print aClass1.Test