再给一个
Dim a() As Integer, b() As Integer n = 4 ReDim a(n - 1) As Integer ReDim b(n - 1) As Integer b(0) = 1: b(1) = 2: b(2) = 3: b(3) = 4 For i = 0 To n ^ n - 1 For j = 0 To n - 1 If a(j) = n Then a(j + 1) = a(j + 1) + 1 a(j) = 0 Else Exit For End If Next j Debug.Print b(a(3)) & b(a(2)) & b(a(1)) & b(a(0)) a(0) = a(0) + 1 Next i