tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,926
- Office Version
- 365
- 2019
- Platform
- Windows
Class Factories have been suggested as a workaround for VBA's lack of a Constructor.
This is what I've come up with:
Class1:
Standard module:
Is this the same as a Class Factory?
Thanks
This is what I've come up with:
Class1:
Code:
Option Explicit
Private pColour As String
Private pMake As String
Public Property Get Colour() As String
Colour = pColour
End Property
Public Property Let Colour(ByVal C As String)
pColour = C
End Property
Public Property Get Make() As String
Make = pMake
End Property
Public Property Let Make(ByVal M As String)
pMake = M
End Property
Private Sub Class_Initialize()
Me.Colour = Col
Me.Make = Mak
End Sub
Standard module:
Code:
Option Explicit
Public Col As String
Public Mak As String
Sub Test()
Col = "Blue"
Mak = "Mini"
Dim abc As Class1
Set abc = New Class1
Debug.Print Col
Debug.Print Mak
Col = "Red"
Make = "Ford"
Dim cde As Class1
Set abc = New Class1
Debug.Print Col
Debug.Print Mak
End Sub
Is this the same as a Class Factory?
Thanks