Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

VBScript UBound Function


❮ Complete VBScript Reference

The UBound function returns the largest subscript for the indicated dimension of an array.

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

Syntax

UBound(arrayname[,dimension])

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

Examples

Example 1

<%

days=Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
response.write(LBound(days) & "<br />")
response.write(UBound(days) & "<br />")

%>

The output of the code above will be:

0
6
Show Example »

Example 2

A two dimensional array:

<%

Dim food(2,3)
food(0,0)="Apple"
food(0,1)="Banana"
food(0,2)="Orange"
food(0,3)="Lemon"
food(1,0)="Pizza"
food(1,1)="Hamburger"
food(1,2)="Spaghetti"
food(1,3)="Meatloaf"
food(2,0)="Cake"
food(2,1)="Cookie"
food(2,2)="Icecream"
food(2,3)="Chocolate"
response.write(LBound(food,1) & "<br />")
response.write(UBound(food,1) & "<br />")
response.write(LBound(food,2) & "<br />")
response.write(UBound(food,2) & "<br />")

%>

The output of the code above will be:

0
2
0
3
Show Example »

❮ Complete VBScript Reference
×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.