i have an array path… this array contains a list of nested array paths. it could look something like this:
path( 0 1 2 3 4 5 6 7 8 )
"1" | 1, 1, 1, 1, 1, 1, 1, 1, 1 |
"2" | 4, 3, 1, 4, 2, 3, 4, 3, 2 |
"3" | 1, 1, , 2, 1, 2, 3, 3, 2 |
"Val" A, B, C, D, E, F, G, H, I
now i have a small loop to get the maximum of the second row.
x = 1
For c = 0 To UBound(path)
If IsArray(path(c)) Then
If CInt(path(c)(x)) <= maxDimension1 Then
maxDimension1 = CInt(path(c)(x))
End If
End If
Next
redim preserve pathValues(maxDimension1 - 1)
i must now find the maximum number of elements for the elements in row “2” and redim the array-Element in pathValues to this.
i tried:
For Dimension2 = 1 To maxDimension1
For c = 0 To UBound(Path)
If IsArray(Path(c)) Then
If CInt(Path(c)(x)) = Dimension2 Then
If CInt(Path(c)(2)) >= maxDimension2 Then
maxDimension2 = CInt(Path(c)(2))
End If
End If
End If
redim PathValues(c)(maxDimension2) //Syntax Error
next
next
is there a way to avoid a workaround with multidimensional array?
for explanation: the pathValues would look like this in the end:
PathValues() = (C,(E, I),(B, F, H),(A, D, G))
I fixed it by recursively calling a function that uses x as “depth” and the full path to create one single array containing empty elements for the values that get written in later.
one just needs to add a statement sorting out the upper bounds you do not want because they belong to other arrays. for all else it works fine