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
广告