Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

lbound Method (Windows Scripting - JScript)

Updated: March 2009

Returns the lowest index value used in the specified dimension of a VBArray.

                      safeArray.lbound(dimension)
safeArray

Required. A VBArray object.

dimension

Optional. The dimension of the VBArray for which the lower bound index is wanted. If omitted, lbound behaves as if a 1 was passed.

If the VBArray is empty, the lbound method returns undefined. If dimension is greater than the number of dimensions in the VBArray, or is negative, the method generates a "Subscript out of range" error.

The following example consists of three parts. The first part is VBScript code to create a Visual Basic safe array. The second part is JScript code that determines the number of dimensions in the safe array and the lower bound of each dimension. Since the safe array is created in VBScript rather than Visual Basic, the lower bound will always be zero. Both of these parts go into the <HEAD> section of an HTML page. The third part is the JScript code that goes in the <BODY> section to run the other two parts.

<HEAD>
<SCRIPT LANGUAGE="VBScript">
<!--
Function CreateVBArray()
   Dim i, j, k
   Dim a(2, 2)
   k = 1
   For i = 0 To 2
      For j = 0 To 2
         a(j, i) = k
         k = k + 1
      Next
   Next
   CreateVBArray = a
End Function
-->
</SCRIPT>

<SCRIPT LANGUAGE="JScript">
<!--
function VBArrayTest(vba){
   var i;
   var a = new VBArray(vba);
   var s = "";
   for (i = 1; i <= a.dimensions(); i++)
   {
      s += "The lower bound of dimension ";
      s += i + " is ";
      s += a.lbound(i);
      s += ".<BR>";
   }
   return (s);
}
-->
</SCRIPT>
</HEAD>

<BODY>
<SCRIPT language="jscript">
   document.write(VBArrayTest(CreateVBArray()));
</SCRIPT>
</BODY>

Date

History

Reason

March 2009

Modified example code so that it outputs the results from both dimensions.

Content bug fix.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.