After playing with this method, I finally found a solution. Here he is:
Private Sub Iterate(ByVal iFrom As Integer, ByVal iTo As Integer, ByVal Depth As Integer, ByVal iValues As Integer()) For i = iFrom To iTo iValues(Depth - 1) = i If Depth - 1 > 0 Then Iterate(i, iTo, Depth - 1, iValues) Else 'Do stuff, in this case print the current iValues Console.WriteLine(String.Join("", iValues.Select(Function(x) x.ToString).ToArray)) End If Next Console.WriteLine() End Sub 'Usage: Dim iValueArray(Depth) As Integer Iterate(0, 1, 2, iValueArray)
Cobold
source share