这是ChatGPT给的代码:
Public Sub ListCombinations(n As Integer, m As Integer)
Dim a() As Integer
ReDim a(1 To m)
Combination 1, n, a, 1, m
End Sub
Private Sub Combination(t As Integer, n As Integer, a() As Integer, k As Integer, m As Integer)
Dim i As Integer
If k > m Then
Debug.Print Join(a, " ")
Exit Sub
End If
For i = t To n
a(k) = i
Combination i + 1, n, a, k + 1, m
Next i
End Sub
运行报错!
Debug.Print Join(a, " ")
“无效的过程调用或参数!”
改MsgBox也不行,请高手帮忙看看如何修改可以吗?