Short answer: All of them.
Let's analyse what @hans-passant has written;
Answer to Overloading a method in com visible dll
COM does not have support for member overloads, each name must be unique. An inevitable side-effect of IDispatch::GetIDsOfNames()
. The function that the script interpreter uses to translate "Write" as used in the scripting code to a dispid. The method still exists, there's just no way to get GetIDsOfNames()
to return its dispid. The type library exporter solves this problem by renaming the overloaded method, it will be Write_2()
.
It's in two parts
- Explaining the behaviour of
IDispatch::GetIDsOfNames()
- How the Type Library Exporter solves uniqueness issue.
It doesn't say they are not available, on the contrary they have been renamed to avoid the uniqueness constraint that IDispatch::GetIDsOfNames()
has when assigning DISPID
to the method name.
So all three overloads are available just renamed using the following format
oList.IndexOf
oList.IndexOf_2
oList.IndexOf_3
Note: There is no IndexOf_1
because the first overload always takes the original method name and subsequent overloads start from _2
onwards.
Depending on how the Type Library Exporter renames the overloads will depend which one takes which set of arguments, the only way to work this out is trial and error.
Quick attempt at a test
Dim oList
Set oList = CreateObject("System.Collections.ArrayList")
oList.Add "bar"
oList.Add "foo"
WScript.Echo oList.IndexOf("foo", 0)
WScript.Echo oList.IndexOf_2("foo", 0, 1)
WScript.Echo oList.IndexOf_3("foo")
Output:
1
-1
1
Why do the two statements fail with different errors?
If we go back to your original example
Dim oList
Set oList = CreateObject("System.Collections.ArrayList")
'oList.IndexOf "foo" 'Error: Invalid procedure call or argument: 'IndexOf'
oList.IndexOf "foo", 0
'oList.IndexOf "foo", 0, 1 'Error: Wrong number of arguments or property assignment was not valid: 'IndexOf'
Statement one and three fail with different errors due to how VBScript evaluates the method signatures. The correct signature in the above example accepts two arguments so the first statement;
oList.IndexOf "foo"
will fail because the only matching signature has two arguments not one hence the error;
Invalid procedure call or argument: 'IndexOf'
The third statement
oList.IndexOf "foo", 0, 1
contains one more argument then the expected signature so instead of not finding a match it finds one but reports;
Wrong number of arguments or property assignment was not valid: 'IndexOf'
as the number of arguments exceeds what is expected by the method signature IndexOf(arg, arg)
.
Useful Links