- VBScript 教程
- VBScript - 主頁
- VBScript - 概述
- VBScript - 語法
- VBScript - 啟用
- VBScript - 位置
- VBScript - 變數
- VBScript - 常量
- VBScript - 運算子
- VBScript - 判斷
- VBScript - 迴圈
- VBScript - 事件
- VBScript - Cookie
- VBScript - 數字
- VBScript - 字串
- VBScript - 陣列
- VBScript - 日期
- VBScript 高階
- VBScript - 過程
- VBScript - 對話方塊
- VBScript - 面向物件
- VBScript - 正則表示式
- VBScript - 錯誤處理
- VBScript - 雜項語句
- VBScript 有用資源
- VBScript - 問題與解答
- VBScript - 快速指南
- VBScript - 有用資源
- VBScript - 討論
VBScript UBound 函式
UBound 函式返回指定陣列的最大下標。因此,此值對應於陣列的大小。
語法
UBound(ArrayName[,dimension])
ArrayName,必需引數。此引數對應於陣列的名稱。
dimension,可選引數。此引數獲取一個整數值,該值對應於陣列的維度。如果為“1”,則它返回第一個維度的下界;如果為“2”,則它返回第二個維度的下界,依此類推。
示例
<!DOCTYPE html>
<html>
<body>
<script language = "vbscript" type = "text/vbscript">
Dim arr(5)
arr(0) = "1" 'Number as String
arr(1) = "VBScript" 'String
arr(2) = 100 'Number
arr(3) = 2.45 'Decimal Number
arr(4) = #10/07/2013# 'Date
arr(5) = #12.45 PM# 'Time
document.write("The Largest Subscript value of the given array is : " & UBound(arr))
' For MultiDimension Arrays :
Dim arr2(3,2)
document.write(
"The Largest Subscript of the first dimension of arr2 is : " & UBound(arr2,1) & "<br />")
document.write(
"The Largest Subscript of the Second dimension of arr2 is : " & UBound(arr2,2) & "<br />")
</script>
</body>
</html>
當上述程式碼另存為 .HTML 格式,並在 Internet Explorer 中執行後,它將產生以下結果 -
The Largest Subscript value of the given array is : 5 The Largest Subscript of the first dimension of arr2 is : 3 The Largest Subscript of the Second dimension of arr2 is : 2
vbscript_arrays.htm
廣告