To determine the size and dimensions of the array, first you need to find the length using the
array.Length. Now that you have the total number of elements of both dimensions you can use UBOUND to determine the highest index number of the first dimension.
Then take the Length and divide it by the index number returned by UBOUND and you will have the size of the second dimension. Don't forget to add one to the value returned by UBOUND because it only returns the highest index number, not the actual number of elements. And then subtract one to get the value back to the highest index number of the second dimension.
Example:
CODE
Dim arr(3, 4) As Integer
Dim firstDim As Integer = UBound(arr)
Dim secDim As Integer = CInt((arr.Length / (UBound(arr) + 1)) - 1)
MsgBox((firstDim & ", " & secDim))
The result in the MsgBox will be
3, 4Keep in mind when declaring arrays in VB that you are specifying the highest index number, not the actual number of elements. So an array of 3 by 4 will actually have 20 elements.
First dimension indexes will be 0 - 3 for a total of 4 elements and second dimension indexes will have 0 - 4 for a total of 5 elements.