passing a two-dimensional array to a function

I am trying to write an array sorting routine for a two-dimensional array. My problem is I can’t quite figure out how to declare the two-dimensional array within the function. If I declare it as “MyArray() as string” then the array in the function is one dimensional. I’ve tried “MyArray(,) as string” but that didn’t work either. I can’t find any relevant example code. Any help is appreciated.

This is the correct way - so it should work.

This is the method:

Private Sub SortProcedure(arr(,) As String) ... End Sub

That’s how you call it:

[code]Dim arr(1, 1) As String
arr(0, 0) = “A”
arr(0, 1) = “B”
arr(1, 0) = “C”
arr(1, 1) = “D”


Why would you declare the two dimensional (2D) array in the sorting function for the 2D array? That would make it rather difficult to use the function as a general sorting mechanism for 2D arrays as it could ONLY sort the specific array created inside itself.

You start with the 2D array (declared in the window or a class or wherever) and pass it to the sorting routine as a parameter as Eli described.

The sorting routine then sorts the 2D array.