I have a class with 3 constructors.
Sub Constructor()
End Sub
Sub Constructor(oActions() As Action)
Actions = oActions
End Sub
Sub Constructor(ParamArray acts As Action)
Actions = acts
End Sub
If I call the first version with no parameters I get “There is more than one item with this name and it’s not clear to which this refers”.
In the past when this happens it is because I have not created an empty constructor.
I did some testing and it seems as long as I have one constructor with a ParamArray I can not use an empty constructor.
Does a paramarray constructor preclude a blank constructor?
the one for paramarray blocks the default constructor.
Thanks Christian. I assume this means the “indefinite number of values” the paramarray allows includes 0. I can workaround - it just seemed odd to me.
You can get around this another way:
Sub Constructor (firstAction As Action, ParamArray acts() As Action)
acts.Insert 0, firstAction
That form will always expect at least one parameter.
But in this case, I’d probably just check acts.Ubound.
Norman_P
(Norman P)
6
Get rid of the no param version and just have the paramarray version check for nil if you pass no parameter
Sub Constructor(ParamArray acts As Action)
if acts <> nil then Actions = acts
End Sub
Thanks Eli, Kem and Norman. I had already modified to Norman’s suggestion.