I have a class State and some sub inside it that takes a Scripting.Dictionary as an argument. However when I try to pass a dictionary there, I get a wrong number of arguments or invalid property assignment error. I can't figure out what's wrong.
'Sub insite State class
Sub addSecondItems(itemsDict As Object)
MsgBox ("start addSecondItems")
End Sub
Sub test()
Dim stateCopy As State
Set stateCopy = New State
...
Dim dict1 As Object
Set dict1 = CreateObject("Scripting.Dictionary")
stateCopy.addSecondItems (dict1) 'error here
...
End Sub
At the same time
Sub testPetDict()
Dim petDict As Object
Set petDict = CreateObject("Scripting.Dictionary")
Call readPetDict(petDict)
End Sub
Sub readPetDict(petDict As Object)
Dim year As Integer
For year = 2014 To 2017
MsgBox (year & ". " & petDict(year))
Next
End Sub
works fine.
What may be wrong here and why the second case works, while the first fails?
stateCopy.addSecondItems dict1or useCall