Vbscript-lbound-function

提供:Dev Guides
移動先:案内検索

VBScript LBound関数

LBound関数は、指定された配列の最小の添え字を返します。 したがって、配列のLBoundはゼロです。

構文

LBound(ArrayName[,dimension])
  • ArrayName 、必須パラメーター。 このパラメーターは、配列の名前に対応しています。
  • dimension 、オプションのパラメーター。 これは、配列の次元に対応する整数値を取ります。 '1’の場合、最初の次元の下限を返します。 '2’の場合、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>

上記のコードをlとして保存し、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