How to find out the size of a variable-size array ?

A

Adrian

Hi,

Is there a function to find out the size of a variable size array ?
Thanks.

regards,
Adrian
 
R

Rob van Gelder

UBound / LBound are what you're after.

If you want to know the number of dimensions: Check my website for "Number
of Dimensions"
(posted here for archive)

Sub test()
Dim arr(1, 2, 3, 4) As Long
Dim i As Long

On Error Resume Next
Do: i = i - (LBound(arr, i + 1) * 0 = 0): Loop Until Err.Number
On Error GoTo 0

MsgBox i
End Sub
 
Top