mbmast
mbmast

Reputation: 1100

Excel VBA Add Method of SortedList Class from MSCORLIB.DLL Produces Compile Time Error: Expected: =

I'm writing some Excel VBA code and I'm using the SortedList class from the MSCORLIB.DLL as documented by Microsoft: SortedList.Add (Object, Object). I'm getting a compile time error that I just don't understand:

enter image description here

Here's how I included MSCORLIB.DLL into my project:

enter image description here

Additionally, I have the Windows feature .NET Framework 3.5 turned on.

enter image description here

Why am I getting this compiler error?

Upvotes: 0

Views: 308

Answers (1)

braX
braX

Reputation: 11735

Remove the parenthesis for subroutines that do not return a value.

sl.Add "key", "Value" 

Or if it does return a value, that's when you use parenthesis.

x = sl.Add("key", "Value") 

You may run into an Automation error in this case tho.

But at least it compiles, and that's what your question was about (VBA syntax).

Upvotes: 0

Related Questions