Search w3schools.com:

SHARE THIS PAGE

VBScript LBound Function


VBScript Reference Complete VBScript Reference

The LBound function returns the smallest subscript for the indicated dimension of an array.

Note: The LBound for any dimension is ALWAYS 0.

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

Syntax

LBound(arrayname[,dimension])

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

Examples

Example 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 output of the code above will be:

0
6

Try it yourself »

Example 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 output of the code above will be:

0
2
0
3

Try it yourself »

VBScript Reference Complete VBScript Reference

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]