1

See bellow VBE tells it expects an "=" on line 3 inspite of the fact that .Add is a Sub, I don't understant why?

1  Sub Set_Params(key As String, value As Variant)
2      Dim Tranasitions as Collection
3      Transitions.Add (value, key)
4  End Sub
sgp667
  • 1,797
  • 2
  • 20
  • 38

3 Answers3

3

It is because your code doesn't know what Tranasitions is, you have a typo in the declaration (the Dim line).

So to fix it, fix the declaration:

Dim Transitions as Collection

And then remove the () from the call, you don't use them with subs in VBA (unless you put Call in front):

Transitions.Add value, key
T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
miradulo
  • 28,857
  • 6
  • 80
  • 93
0

Firstly, refer to the collection using a consistent name.

Then, use Call Transitions.Add etc. or drop the brackets.

Vba has this arcane calling syntax.

Bathsheba
  • 231,907
  • 34
  • 361
  • 483
0

Remove the parenthesis.

Sub Set_Params(key As String, value As Variant)
    Dim Transitions as New Collection
    Transitions.Add value, key
End Sub

Also, you have to actually create a new instance of Transitions. Oh, and you spelled Transitions as Tranasitions when you declared it. Turn Option Explicit on so that doesn't happen anymore.

RubberDuck
  • 11,933
  • 4
  • 50
  • 95