Creating a "typed" array

I have a method with a ParamArray of Variants:

Sub SomeMethod(ParamArray vars() As Variant)

When I do:

AnObject.SomeMethod(True, False)

it will not compile, because this is understood by the compiler as a ParamArray of Booleans.
The only way known to me, is to write this code:

Dim args() As Variant args.Append(True) args.Append(False) AnObject.SomeMethod(args)
Is this verbosity necessary, or is there a way to reduce that to a one-liner?

Thanks, but it has to be an array of Variants, not an array of Booleans (see the method definition).

It compiles for me. Are you sure nothing else is going on?

[code]Class Class1
Sub SomeMethod(ParamArray vars() As Variant)
for i As integer = 0 to vars.Ubound
MsgBox vars(i).StringValue
next
End Sub
End Class

Sub Action() //PushButton
dim AnObject As new Class1
AnObject.SomeMethod(True, False)
End Sub
[/code]

Sorry, it is not a ParamArray, it is an array of Variants (it’s an external library, so I can’ change it to a ParamArray):

Sub SomeMethod(vars() As Variant)

ok, you can add this global method to package an array

Function ToVariantArray(ParamArray vars() As Variant) As Variant() return vars End Function

and then…

 AnObject.SomeMethod( ToVariantArray(True, False) )

and use a better name :slight_smile: