I got that little function(I changed the name of variables)
Private Function everythingLinked(ByRef myClass As cls, ByVal found As Boolean) As Boolean
If Not found AndAlso myClass.checked = False Then
myClass.checked = True
For i = 0 To myClass.numLink
If Not found Then
found = everythingLinked(masterArrayOfCls(myClass.linkNum(i)), myClass.isMiddlePoint)
End If
Next
End If
Return found
End Function
I want to rewrite it so it would only be loop and no recursion and I'm currently lost, anyone could give me some direction or anything?
edit What it does. (English is not my native language sorry)
I'm passing a class to this function(with a starting value for found as false) to know if it is linked to the middle of the tree.
The class got an array with a maximum of 4 link to other class and it can be circular(this is why I have a checked_link boolean).
It does the recursion until there is no more link(return false) to check or until it find the middle link(return true).
edit
for an example, this
in pos 0 got link with 1
in pos 0 got link with 6
in pos 1 got link with 0
in pos 1 got link with 7
in pos 2 got link with 3
in pos 2 got link with 8
in pos 3 got link with 4
in pos 3 got link with 2
in pos 4 got link with 3
in pos 5 got link with 11
in pos 6 got link with 0
in pos 7 got link with 8
in pos 7 got link with 1
in pos 8 got link with 9
in pos 8 got link with 2
in pos 8 got link with 7
in pos 8 got link with 14
in pos 9 got link with 8
in pos 10 got link with 11
in pos 10 got link with 16
in pos 11 got link with 5
in pos 11 got link with 10
in pos 11 got link with 17
in pos 12 got link with 13
in pos 13 got link with 12
in pos 13 got link with 19
in pos 14 got link with 15
in pos 14 got link with 8
in pos 14 got link with 20
in pos 15 got link with 14
in pos 16 got link with 10
in pos 16 got link with 22
in pos 17 got link with 11
in pos 18 got link with 19
in pos 18 got link with 24
in pos 19 got link with 20
in pos 19 got link with 13
in pos 19 got link with 18
in pos 19 got link with 25
in pos 20 got link with 21
in pos 20 got link with 14
in pos 20 got link with 19
in pos 20 got link with 26
in pos 21 got link with 20
in pos 22 got link with 23
in pos 22 got link with 16
in pos 22 got link with 28
in pos 23 got link with 22
in pos 23 got link with 29
in pos 24 got link with 18
in pos 25 got link with 19
in pos 26 got link with 27
in pos 26 got link with 20
in pos 27 got link with 28
in pos 27 got link with 26
in pos 28 got link with 22
in pos 28 got link with 27
in pos 29 got link with 23
middlepoint would be pos 15
the code above can prove that every position can be linked with the middlepoint
so initial arg would be
everythingLinked(random pos, false)
and in this case it would be always true