Hi all, I'm upgrading my VB6 project to VB.NET and I found one of the problem below relating to dimensional array.

Here's my VB6 coding :
Code:
Private Function ConvertMatrixToBase0(ByVal MyMat() As Double) As Double()

        Dim i, j As Long
        Dim ConvMat() As Double


        On Error GoTo ErrHandler_ConvertMatrixToBase0


        If MultiDimensional(MyMat) = False Then  '1-dimensional array

            ReDim ConvMat(UBound(MyMat, 1) - 1)

            For i = 1 To UBound(MyMat, 1)
                ConvMat(i - 1) = MyMat(i)
            Next i

            ConvertMatrixToBase0 = ConvMat

        Else 'multi-dimensional array

            ReDim ConvMat(UBound(MyMat, 1) - 1, UBound(MyMat, 2) - 1)

            For i = 1 To UBound(MyMat, 1)
                For j = 1 To UBound(MyMat, 2)
                    ConvMat(i - 1, j - 1) = MyMat(i, j)
                Next j
            Next i

            ConvertMatrixToBase0 = ConvMat

        End If

        Exit Function


ErrHandler_ConvertMatrixToBase0:

    End Function

When i port it over to VB.NET, i encountered error message 'ReDim' cannot change the number of dimensions of an array. for the line highlighted in red. And I suspect that VB.NET need to always define the exact dimension of the array during the declaration. But for the function above, for the array of 'MyMat()', I do not know what is the exact dimension every time it runs, and that is why i need to check the dimension of the array.

My question is do we have any solution in dealing unknown dimension array in VB.NET?
As in VB6, we can just define Array() instead of Array (,) in VB.NET.