Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to convert a single dimension array to two dimensional array
#4
Solved: 9 Years, 5 Months, 4 Weeks ago
In this case you can use that single dimensional array to create double dimensional array.

Get the count of that array and loop through the same array and assign same values to two dimensional array:

Code:
Dim TwoDimArray()

singleDimArray = Array("a", "b", "c", "d", "e", "f", "g")

ReDim TwoDimArray(UBound(singleDimArray), 1)

For i = 0 To UBound(singleDimArray) Step 2
    For j = 0 To 1 Step 1
        If j = 0 Then
            TwoDimArray(i, j) = singleDimArray(i)
            Else If i<6 Then
                TwoDimArray(i, j) = singleDimArray(i+1)
            End IF            
        End If
    Next
Next

After running this code remove empty element from the array. This code will traverse your single dimensional array and insert each value from the single dimensional array to two dimensional array.
Reply


Messages In This Thread
RE: How to convert a single dimension array to two dimensional array - by pranikgarg - 02-10-2014, 03:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  String Array Declaration Bhuvana 0 1,013 01-07-2020, 12:59 PM
Last Post: Bhuvana
  How To Capture Array Value into Excel Worksheet? Studymode 0 1,421 01-09-2018, 08:37 AM
Last Post: Studymode
  Choosing element from array marvson 1 1,908 06-29-2016, 02:55 PM
Last Post: Ankesh
  [UFT] Get Item of ListBox and convert it to array felino 1 2,444 11-26-2015, 02:20 PM
Last Post: felino
  Need a logic in array - QTP surestud 4 3,192 08-20-2015, 02:47 PM
Last Post: cuongtv

Forum Jump:


Users browsing this thread: 1 Guest(s)