tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,926
- Office Version
- 365
- 2019
- Platform
- Windows
This is taken from the following article:
It talks about class factories:
When an object is created using this class, the class internally sets the colour of the car to be red when created. If we wanted to create a Car object which was blue, we would have to set its colour property to blue after creation:
My question is: why would you want to create a car object and set its colour property to be blue BEFORE creation?
Code:
https://datapluscode.com/general/no-constructor-no-problem/
It talks about class factories:
Code:
Option Explicit
Dim sColour As String
Public Property Let Colour(ByVal Value As String)
sColour = Value
End Property
Public Property Get Colour() As String
Colour = sColour
End Property
Private Sub Class_Initialize()
sColour = "Red"
End Sub
Public Sub PrintColour()
Debug.Print "The Car Colour is " & sColour
End Sub
When an object is created using this class, the class internally sets the colour of the car to be red when created. If we wanted to create a Car object which was blue, we would have to set its colour property to blue after creation:
My question is: why would you want to create a car object and set its colour property to be blue BEFORE creation?