UBound Function

Tips >>ASP Functions

WANTS TO MAKE SOFTWARE WITHOUT KNOWLEDGE OF ASP? CLICK HERE

The UBound function returns the upper limit for the number of elements in an array (the elements can be empty). The UBound function returns the largest subscript for the indicated dimension of an array. Returns the largest available subscript for the indicated dimension of an array. The UBound function is used with the LBound function to determine the size of an array. Use the LBound function to find the lower limit of an array dimension. The default lower bound for any dimension is always 0.

Tip :- Use the UBound function with the LBound function to determine the size of an array.

The Syntax of the UBound function is :-

UBound(arrayname[,dimension])

Its Description is :-

Parameter Description
arrayname Required. The name of the array variable
dimension Optional. Which dimension's upper bound to return. 1 = first dimension, 2 = second dimension, and so on. Default is 1

Example#1 :-

Code :-
dim a(10)
a(0)="Saturday"
a(1)="Sunday"
a(2)="Monday"
a(3)="Tuesday"
a(4)="Wednesday"
a(5)="Thursday"
document.write(UBound(a))
document.write("<br />")
document.write(LBound(a))
Output :-
10
0


Example#2 :-

Dim A(100,3,4)

Statement Return Value
Ubound(A, 1) 99
Ubound(A, 2) 2
Ubound(A, 3) 3

There is One Mandatory Argument :-

Example#3 :-
It explains the ArrayName Argument

Code :-
<% Dim katarray(5) %>
<% katarray(0) = "Mountain lion" %>
<% katarray(1) = "Bobcat" %>
<% katarray(2) = "Jaguar" %>
<% =UBound(katarray) %>
Output :-
5

There is One Optional Argument :-

Example#4 :-
It explains the Dimension Argument

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

 
E-mail : sales@virtualsplat.com
Phone : +91-9892413501

+91-9967648641

+91-9967648641