disgracept
Member
- Local time
- Today, 04:01
- Joined
- Jan 27, 2020
- Messages
- 45
Good afternoon all.
Since VBA doesn't have parameterized constructors, i've been trying to implement a factory in a class.
This is the code í've done so far, after looking up in the net:
But when i try to use this to create an instance of my class with this code:
i get a
What is wrong? Couldn't find a reason anywhere...
Thanks
Since VBA doesn't have parameterized constructors, i've been trying to implement a factory in a class.
This is the code í've done so far, after looking up in the net:
Code:
Option Compare Database
Option Explicit
Private myImovelID As Integer
Public Function Create(ByVal imovelID As Integer) As cls_EditImovel
With New cls_EditImovel
.ID = imovelID
Set Create = .Self
End With
End Function
Public Property Get Self() As cls_EditImovel
Set Self = Me
End Property
Public Property Let ID(myID As Integer)
myImovelID = myID
End Property
Public Property Get ID() As Integer
ID = myImovelID
End Property
But when i try to use this to create an instance of my class with this code:
Code:
Public Sub newImovel()
Dim novo As cls_EditImovel
Set novo = cls_EditImovel.Create(2)
Debug.Print novo.ID
End Sub
i get a
Run-time error '424': Object required
in the line Set novo =...
What is wrong? Couldn't find a reason anywhere...
Thanks
Last edited: