Hi, Is there a function to find out the size of a variable size array ? Thanks. regards, Adrian
A Adrian Jul 6, 2004 #1 Hi, Is there a function to find out the size of a variable size array ? Thanks. regards, Adrian
R Rob van Gelder Jul 6, 2004 #2 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
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