.netvb.netparamarray

Two ParamArrays as Parameter in Function


I was just trying to write a function like this:

Public Function myGetAttribute(ByVal xmlFileName As String, _
                                   ByVal ParamArray elementV() As String, _
                                   ByVal ParamArray attributesV() As String) As Collection

This is not working

"End of parameter list expected. Cannot define parameters after a paramarray parameter."

Why is it not possible to put two paramarrays as parameters and what is a workaround?


Solution

  • There can be only one ParramArray and it has to be the last. It looks like you want pass two arrays as parameters to your sub and not an an unknown number of parameters.

    Public Function myGetAttribute(ByVal xmlFileName As String, _
                                       ByVal elementV() As String, _
                                       ByVal attributesV() As String) As Collection
    

    More here: MSDN