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,670
  • 2
  • 19
  • 36

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
  • 959,406
  • 173
  • 1,780
  • 1,769
miradulo
  • 26,763
  • 6
  • 73
  • 90
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
  • 227,678
  • 33
  • 352
  • 470
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,070
  • 4
  • 46
  • 94