Reputation: 452
I am struggling to make the thing working using VBA Class modules
First class module is tDate
'--- Class1 tDate
Public d as Integer
Public m as Integer
Public y as Integer
'--- some get/let properties for d,m,y
Second class module is tRate
'--- Class2 tRate
Public pDate1 as New tDate
Public dValue as Double
'--- Now i'm trying to code properties
Public Property Get FirstDate() As tDate
FirstDate = pDate1
End Property
Public Property Set FirstDate(vDate As tDate)
pDate1 = vDate ' <---- ???
End Property
In simple module I have the following sub to test the class
Sub test()
Dim myDate As New tDate
Dim r1 As New tRate
myDate.SetDate "20/10/1996"
r1.FirstDate = myDate ' <----- "Compile error : Invalid use of property"
End Sub
What is the best solution to link small class1 object as a property of bigger class2?
Thank you!! Nicholas
Problem resolved using Set :
Public Property Get FirstDate() As tDate
Set FirstDate = pDate1
End Property
Public Property Set FirstDate(vDate As tDate)
Set pDate1 = vDate
End Property
and here as well :
Set r1.FirstDate = myDate
Upvotes: 3
Views: 1263
Reputation: 78175
Use Set
to assign an object to a variable.
Set r1.FirstDate = myDate
Upvotes: 3