The ubund function method in JavaScript returns the maximum index value used in the specified dimension of VBArray. How to use:
The code copy is as follows:
safeArray.ubund(dimensionality)
Among them, safeArray is a must-have option. is a VBArray object.
dimension is optional. To know the dimension of VBArray in its index upper bound. If ignored, ubund processes this parameter as 1.
If VBArray is empty, the ubund method returns undefined. If dim is greater than the dimension of VBArray or is negative, the method will produce an "subscript out of bounds" error.
Example
The following example includes three parts. The first part is VBScript code used to create a Visual Basic secure array. The second part is JScript code, which determines the dimensions of the secure array and the upper bound of each dimension. Both parts are placed in the <HEAD> section of the HTML page. The third part is the JScript code located in the <BODY> part, which is used to run the other two parts.
The code copy is 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.dimensionals(); i++)
{
s = "The upper bound of dimension ";
s += i + " is ";
s += a.ubund(i)+ ".
";
return(s);
}
}
-->
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT language="jscript">
document.write(VBArrayTest(CreateVBArray()));
</SCRIPT>
</BODY>