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

  • Thread starter Thread starter Adrian
  • Start date Start date
A

Adrian

Hi,

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

regards,
Adrian
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top