Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
LBOUND, UBOUND Functions Details
◄Summary► ◄Details► ◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
LBOUND(array [,dimension%])
UBOUND(array [,dimension%])
Usage Notes
■ The UBOUND function can be used with the LBOUND function to determine
the size of an array.
■ Use REDIM with the PRESERVE keyword to change the size of an array to
the exact size you need. Use UBOUND to tell how many filled elements
there are in the array since they will all be filled.
See: ◄REDIM Statement►
■ LBOUND and UBOUND return the values listed below for an array with the
following dimensions:
DIM A(1 TO 100, 0 TO 3, -3 TO 4)
Usage Value Returned
═══════════ ════════════════════════════════════════════════════
UBOUND(A,1) 100
UBOUND(A,2) 3
UBOUND(A,3) 4
LBOUND(A,1) 1
LBOUND(A,2) 0
LBOUND(A,3) -3
■ You can use the shortened syntax UBOUND(array) or LBOUND(array) for one-
dimensional arrays, because the default value for dimension% is 1.
■ The default lower bound for any dimension is either 0 or 1, depending on
the setting of the OPTION BASE statement. If OPTION BASE is 0, the
default lower bound is 0; if OPTION BASE is 1, the default lower bound
is 1. See: ◄OPTION BASE Statement►
■ Arrays dimensioned using the TO clause in the DIM statement can have any
integer value as a lower bound. See: ◄DIM Statement►