Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

toArray Method

Returns a standard JScript array converted from a VBArray.

function toArray() : Array


The conversion translates the multidimensional VBArray into a single dimensional JScript array. The toArray method appends each successive dimension to the end of the previous one. For example, a VBArray with three dimensions and three elements in each dimension converts to a JScript array as follows:

Suppose the VBArray contains: (1, 2, 3), (4, 5, 6), (7, 8, 9). After translation, the JScript array contains: 1, 2, 3, 4, 5, 6, 7, 8, 9.

There is currently no way to convert a JScript array into a VBArray.


The following example consists of three parts. The first part is VBScript code that creates a Visual Basic safe array. The second part is JScript code that converts the Visual Basic safe array to a JScript array. Both of the first and the second parts go into the <HEAD> section of an HTML page. The third part is the JScript code that goes into the <BODY> section to run the other two parts.

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
   CreateVBArray = a
End Function

function VBArrayTest(vbarray)
   var a = new VBArray(vbarray);
   var b = a.toArray();
   var i;
   for (i = 0; i < 9; i++) 



Version 3

See Also

dimensions Method | getItem Method | lbound Method | ubound Method

Applies To: VBArray Object

© 2015 Microsoft