VBScript LBound Function



The LBound Function returns the smallest subscript of the specified array. Hence, LBound of an array is ZERO.

Syntax

LBound(ArrayName[,dimension])
  • ArrayName, a Required parameter. This parameter corresponds to the name of the array.

  • dimension, an Optional Parameter. This takes an integer value that corresponds to the dimension of the array. If it is '1', then it returns the lower bound of the first dimension; if it is '2', then it returns the lower bound of the second dimension and so on.

Example

<!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>

When the above code is saved as .html and executed in Internet Explorer, it produces the following result−

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
Advertisements