SubName: Create2dArray
Author: I think it´s from @Erel
Description: Creates a 2D Array from an Array
Tags: 2d array
Author: I think it´s from @Erel
Description: Creates a 2D Array from an Array
B4X:
Sub Create2DArray(RowLength As Int, Arr() As Int) As Int(,)
Dim rows As Int = Arr.Length / RowLength
Dim td(rows, RowLength) As Int
For r = 0 To rows - 1
For c = 0 To RowLength - 1
td(r, c) = Arr(r * RowLength + c)
Next
Next
Return td
End Sub
'
'Example:
'Dim grid(,) As Int = Create2DArray(3, Array As Int(1, 2, 3, 4, 5, 6))
'grid = 1, 2, 3
' 4, 5, 6
Tags: 2d array