_javascript techniques for using instances of UBound functions in JavaScript

Source: Internet
Author: User

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>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.