Try to create an object with a constructor in vba, I found that answer: pass argument to constructor in vba
But I can not make it works. I missed something.
I use the excel 2010 vba editor. I get a "compile error, syntax error" on InitiateProperties line when I launch MacroTest(), the code here:
in TestClass (created with modul class):
Option Explicit
Private pInfo1 As String
Private pInfo2 As String
Public Sub InitiateProperties(info1 As String, info2 As String)
pInfo1 = info1
pInfo2 = info2
End Sub
in factory (created as modul)
Set CreateTestClass = New TestClass
CreateTestClass.InitiateProperties(info1, info2)
End Function
in Module1*
Sub MacroTest()
Dim myObject As TestClass
myObject = CreateTestClass("hello", "bye")
End Sub
the line :
CreateTestClass.InitiateProperties(info1, info2)
appear to be red
I do not see where I m wrong, it's probably obvious.
Thanks in advance.