VBScript
UBound
function
The VBScript UBound function returns the maximum valid underscript for the specified array of dimensional arrays.
Complete VBScript reference manual
The UBound function returns the maximum undersector indicating the array dimensionality.
Tip:
The UBound function is used in cooperation with the LBound function to determine the size of the array.
Grammar
UBound(arrayname[,dimension])
Parameters
parameter
|
describe
|
arrayname
|
Required.The name of the array variable.
|
dimension
|
Optional.It is necessary to return which one dimension of the lower bound.1 = First dimension, 2 = second dimension, and so on.The default is 1.
|
Instance 1
<script type="text/vbscript">
days=Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
document.write(LBound(days) & "<br />")
document.write(UBound(days) & "<br />")
</script>
The above example output results:
0
6
Try it out . . .
Instance 2
A two-dimensional array:
<script type="text/vbscript">
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"
document.write(LBound(food,1) & "<br />")
document.write(UBound(food,1) & "<br />")
document.write(LBound(food,2) & "<br />")
document.write(UBound(food,2) & "<br />")
</script>
The above example output results:
0
2
0
3
Try it out . . .
Complete VBScript reference manual