UBound Function
Language Items List
Definition:
Returns the value of the largest subscript available for the specified array
dimension.
Syntax 1:
UBound(array [,dimension]}
Syntax Description
array Array variable name.
dimension An optional integer indicating the dimension for which to return the upper
limit. Use 1 to indicate the first dimension, 2 for the second dimension, and so
on. If you do not use dimension, the first dimension (1) is assumed.
Details:
The UBound function is used in conjunction with LBound to determine the size
of a dynamic array. Use UBound to determine the upper limit of a dynamic array
dimension and LBound to determine the lower. The size can be determined by using
the following equation:
UBound return value - LBound return value + 1 = number of elements in this dimension.
The following is an example of the values UBound returns for an array with the
following dimensions:
Dim A(1 To 10, 0 To 5, -6 To 8)
Statement Return Value
UBound(A,1) 1
UBound(A,2) 0
UBound(A,3) -6
See Also:
Dim Statement
LBound Function
ReDim Statement
Static Statement