VBScript LBound 函数
完整的 VBScript 参考手册
LBound 函数返回指示数组维数的最小下标。
注意:任何维数的 LBound 总是 0。
提示:LBound 函数与 UBound 函数共同使用,可以确定数组的大小。
语法
LBound(arrayname[,dimension])
参数 | 描述 |
---|---|
arrayname | 必需。数组变量的名称。 |
dimension | 可选。要返回哪一维的下界。 1 = 第一维, 2 = 第二维,以此类推。默认是 1 。 |
实例
实例 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>
days=Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
document.write(LBound(days) & "<br />")
document.write(UBound(days) & "<br />")
</script>
以上实例输出结果:
0
6
6
实例 2
一个二维数组:
<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>
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>
以上实例输出结果:
0
2
0
3
2
0
3
完整的 VBScript 参考手册