JavaScript Tutorial/MS JScript/VBArray

Материал из Web эксперт
Перейти к: навигация, поиск

VBArray

Syntax



var variable = new VBArray(vbarray)


The VBArray object provides access to Visual Basic safeArrays.

Methods of the VBArray Object

Method Description dimensions() Returns the number of dimensions in the array getItem() Returns the item at a specified location lbound() Returns the lowest index value of the dimension in the array toArray() Returns a JScript array from the VBArray passed ubound() Returns the highest index value of the dimension in the array

VBArray.dimensions()

The dimensions() method returns the number of dimensions of the array.



<html>
    <script LANGUAGE="VBScript">
    <!--
    Function myVBArray()
      Dim i
      Dim j
      Dim k
      k = 1
      Dim myArray(1, 1)
      For i = 0 To 1
        For j = 0 To 1
          myArray(j, i) = k
          document.writeln(k)
          k = k + 1
        Next
        document.writeln("<hr>")
      Next
      myVBArray = myArray
    End Function
    " End Hide -->
    </script>
    <script language="JScript">
    <!--
    var myArray = new VBArray(myVBArray());
    alert(myArray.dimensions());
    -->
    </script>
</html>


VBArray.getItem()

Syntax



vbarray.getItem(index)
    vbarray.getItem(indexA, indexB, ..., indexN)


VBArray.lbound()

Syntax



vbarray.lbound(dimension)
    vbarray.lbound()


VBArray.toArray()

The toArray() method returns a valid JScript array from a VBArray.



<html>
    <script LANGUAGE="VBScript">
    <!--
    Function myVBArray()
      Dim i
      Dim j
      Dim k
      k = 1
      Dim myArray(1, 1)
      For i = 0 To 1
        For j = 0 To 1
          myArray(j, i) = k
          document.writeln(k)
          k = k + 1
        Next
        document.writeln("<br>")
      Next
      myVBArray = myArray
    End Function
    " End Hide -->
    </script>
    <script language="JScript">
    <!--
    var myArray = new VBArray(myVBArray());
    var myJSArray = myArray.toArray();
    alert(myJSArray[0,1]);
    -->
    </script>
</html>


VBArray.ubound()

Syntax



vbarray.ubound(dimension)