Export (0) Print
Expand All

UBound Function

Updated: September 2009

Returns the largest available subscript for the indicated dimension of an array.


                      UBound(arrayname[, dimension])

arrayname

Required. Name of the array variable; follows standard variable naming conventions.

dimension

Optional. Whole number indicating which dimension's upper bound is returned. Use 1 for the first dimension, 2 for the second, and so on. If dimension is omitted, 1 is assumed.

The UBound function is used with the LBound Function to determine the size of an array. LBound returns 0 because the lower bound for any dimension is always 0. Therefore, the length of a dimension is one greater than the output of the UBound function.

The following table shows the values returned by various UBound statements when they are applied to an array that has these dimensions:

Dim A(100,5,4)

Statement

Return value

UBound(A, 1)

100

UBound(A, 2)

5

UBound(A, 3)

4

Date

History

Reason

September 2009

Added information to Remarks.

Customer feedback.

Community Additions

Show:
© 2014 Microsoft