VBScript » Functions » UBound

Syntax:
UBound(ArrayName, Dimension)
ArrayName
The ArrayName argument is the name of the array. Do not include the parenthesis with the array name.
Dimension
The optional Dimension argument is used to identify which index you are determining the upper bounds for in a multi-dimensional array.

The UBound function returns the upper limit for the number of elements in an array (the elements can be empty).

Examples

Code:
<% Dim katarray(5) %>
<% katarray(0) = "Mountain lion" %>
<% katarray(1) = "Bobcat" %>
<% katarray(2) = "Jaguar" %>
<% =UBound(katarray) %>
Output:
5
Language(s): VBScript
Code:
<% Dim arrayfish(4,6) %>
<% arrayfish(0,0) = "Neon tetra" %>
<% arrayfish(0,1) = "Angle fish" %>
<% arrayfish(0,2) = "Discus" %>
<% arrayfish(1,0) = "Golden dojo" %>
<% arrayfish(1,1) = "Clown loach" %>
<% arrayfish(1,2) = "Betta" %>
<% =UBound(arrayfish, 2) %>
Output:
6
Language(s): VBScript

See Also: