The UBound function method in JavaScript is to return the maximum index value used in the specified dimension of VBArray. How to use:
Copy Code code as follows:
Safearray.ubound (Dimension)
Where SafeArray is a required option. is a VBArray object.
Dimension is optional. The dimension of the VBArray to be notified of the upper bound of its index. If omitted, UBound handles the parameter as 1.
If VBArray is empty, the UBound method returns undefined. If the dim is greater than the VBArray dimension or is a negative number, the method produces a "subscript out of Bounds" error.
Example
The following example includes three sections. The first part is the VBScript code used to create a Visual Basic safe array. The second section is JScript code that determines the dimensions of the safe array and the upper bounds of each dimension. Both parts are placed in the <HEAD> section of the HTML page. The third section is the JScript code located in the <BODY> section, which is used to run the other two parts.
Copy Code code as follows:
<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) + ".
";
return (s);
}
}
-->
</SCRIPT>
</HEAD>
<BODY>
<script language= "JScript" >
document.write (Vbarraytest (Createvbarray ()));
</SCRIPT>
</BODY>