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_arrays.htm
廣告
© . All rights reserved.