阅读(1924)
赞(0)
VBScript UBound 函数
2015-09-12 10:12:40 更新
VBScript UBound 函数返回指定维数数组的最大有效下标。
完整的 VBScript 参考手册
UBound 函数返回指示数组维数的最大下标。
提示:UBound 函数与 LBound 函数共同使用,可以确定数组的大小。
语法
UBound(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 参考手册