Share via


ubound Method (JScript 5.6) 

Returns the highest index value used in the specified dimension of the VBArray.


safeArray.ubound(dimension) 

Arguments

  • safeArray
    Required. A VBArray object.
  • dimension
    Optional. The dimension of the VBArray for which the higher bound index is wanted. If omitted, ubound behaves as if a 1 was passed.

Remarks

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

Example

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 upper bound of each dimension. 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, s;

   var a = new VBArray(vba);

   for (i = 1; i <= a.dimensions(); i++)

   {

      s = "The upper bound of dimension ";

      s += i + " is ";

      s += a.ubound(i)+ ".<BR>";

      return(s);

   }

}

-->

</SCRIPT>

</HEAD>



<BODY>

<SCRIPT language="jscript">

   document.write(VBArrayTest(CreateVBArray()));

</SCRIPT>

</BODY>

Requirements

Version 3

Applies To: VBArray Object (JScript 5.6)

See Also

Reference

dimensions Method (JScript 5.6)
getItem Method (JScript 5.6)
lbound Method (JScript 5.6)
toArray Method (JScript 5.6)