Trying to learn Implementation Classes & Class Factories - Parameterized Object Initialisation from this great tutorial,but I get the pic'd error & I can't see where I'm going wrong? I've Predeclared the classes as per tutorial. I'm just before he turns it into an Abstract Factory. I also tried it before creating the cISomethingFactory & got the same error, but in my mind that should have worked.
I'm unsure what the benefit of using a Type for the Properties of the Implementation Class & why he's not using typical module level variables but that's besides the point atm & I can experiment once I get it working.
cSomething
cISomething
cISomethingFactory
ModTest
I'm unsure what the benefit of using a Type for the Properties of the Implementation Class & why he's not using typical module level variables but that's besides the point atm & I can experiment once I get it working.
cSomething
Code:
Private Type TSomething
Bar As Long
Ducky As String
End Type
Private this As TSomething
Implements cISomething
Implements cISomethingFactory
Public Function Create(ByVal initialBar As Long, ByVal initialDucky As String) As cISomething
With New cSomething
.Bar = initialBar
.Ducky = initialDucky
Set Create = .Self
End With
End Function
Public Property Get Self() As cISomething
Set Self = Me
End Property
Public Property Get Bar() As Long
Bar = this.Bar
End Property
Friend Property Let Bar(ByVal NewValue As Long)
this.Bar = NewValue
End Property
Public Property Get Ducky() As String
Ducky = this.Ducky
End Property
Friend Property Let Ducky(ByVal NewValue As String)
this.Ducky = NewValue
End Property
Private Property Get ISomething_Bar() As Long
ISomething_Bar = Bar
End Property
Private Property Get ISomething_Ducky() As Long
ISomething_Ducky = Ducky
End Property
Private Function cISomethingFactory_Create(ByVal initialBar As Long, ByVal initialDuck As String) As cISomething
Set cISomethingFactory_Create = Create(initialBar, initialDuck)
End Function
cISomething
Code:
Public Property Get Bar() As Long
End Property
Public Property Get Ducky() As String
End Property
cISomethingFactory
Code:
Public Property Get Bar() As Long
End Property
Public Property Get Ducky() As String
End Property
Public Function Create(ByVal initialBar As Long, ByVal initialDuck As String) As cISomething
End Function
ModTest
Code:
Sub testImplementClass()
Dim obj As cSomething
With obj.Create(5, "Quack")
Debug.Print .Bar
End With
End Sub