當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


VBScript LBound用法及代碼示例


LBound 函數返回指定數組的最小下標。因此,數組的 LBound 為零。

用法

LBound(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 smallest Subscript value of  the given array is:" & LBound(arr))

         ' For MultiDimension Arrays:
         Dim arr2(3,2)
         document.write(
            "The smallest Subscript of the first dimension of arr2 is:" & LBound(arr2,1) & "<br />")
         document.write(
            "The smallest Subscript of the Second dimension of arr2 is:" & LBound(arr2,2) & "<br />")

      </script>
   </body>
</html>

當上麵的代碼保存為 .html 並在 Internet Explorer 中執行時,它會產生以下結果——

The smallest Subscript value of the given array is:0
The smallest Subscript of the first dimension of arr2 is:0
The smallest Subscript of the Second dimension of arr2 is:0

相關用法


注:本文由純淨天空篩選整理自 VBScript LBound Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。