Returns details of either the indicated dimension or the whole of an array.
LBound[(] array[, dimension] [)]
UBound[(] array[, dimension] [)]
IndexCount[(] array() [)]
array | : varname |
dimension | : iexp |
The LBound function is used with the UBound function to determine the size of an array. Use the UBound function to find the upper limit and LBound the lower limit of an array dimension.
By default, the lower bound for any dimension is always 0. This can be changed using Option Base n.
dimension is a whole number indicating which dimension's lower bound is returned. Use 1 for the first dimension, 2 for the second, and so on. If dimension is omitted, 1 is assumed.
IndexCount() returns the number of array dimensions.
Option Base 1
Debug.Show
Dim MyArray(1 To 10, 5 To 15, 10 To 20)
Dim AnyArray(10)
Trace IndexCount(MyArray())
Trace LBound(MyArray(), 1)
Trace UBound(MyArray(), 1)
Trace LBound MyArray(), 2 // All three functions can be entered ...
Trace UBound MyArray(), 2 // ...without the brackets enclosing the parameters
Trace LBound(MyArray(), 3)
Trace UBound(MyArray(), 3)
Trace IndexCount MyArray()
Debug.Print
Trace IndexCount(AnyArray())
Trace LBound(AnyArray()) // Returns 0 or 1, depending on setting of Option Base.
Trace UBound(AnyArray())
{Created by Sjouke Hamstra; Last updated: 17/05/2017 by James Gaite}