Sunday, March 10, 2013

Size of multi-dimensional array

How to find size of a multi-dimensional array. Use following code to find size of a multi-dimensional array.

'Define 3 dimensional array, with size of the first dimension as 4, with size of the second dimension as 6 and with size of the third dimension as 8

Dim myArray(4,6,8)

'size of the first dimension
MsgBox lbound(myArray,1)        'Returns 0
MsgBox ubound(myArray,1)        'Returns 4

'size of the second dimension
MsgBox lbound(myArray,2)        'Returns 0
MsgBox ubound(myArray,2)        'Returns 6

'size of the third dimension
MsgBox lbound(myArray,3)        'Returns 0
MsgBox ubound(myArray,3)        'Returns 8

1 comment: