Dim combo() As StringPrivate Sub Form_Click() aa 6, "{a,b,c,d,e,f}" End SubSub aa(n As Integer, string1 As String) ReDim combo(n - 1) For i = 2 To Len(string1) '分解出各个元素 tempstr = Mid(string1, i, 1) If tempstr = "}" Then Exit For If tempstr <> "," Then combo(j) = combo(j) & tempstr Else j = j + 1 End If Nextbb n - 1 '调用递归函数 Print "ok" End SubFunction bb(n As Integer) As String '递归函数 If n < 0 Then Exit Function bb = bb(n - 1) & combo(n) Print bb End Function
Dim combo() As String, maxnum As IntegerPrivate Sub Form_Click() aa 6, "{a,b,c,d,e,f}" '总的执行函数(传入值) End SubSub aa(n As Integer, string1 As String) ReDim combo(n - 1) For i = 2 To Len(string1) '分解出各个元素 tempstr = Mid(string1, i, 1) If tempstr = "}" Then Exit For If tempstr <> "," Then combo(j) = combo(j) & tempstr Else j = j + 1 End If Next maxnum = n - 1Do While maxnum >= 0 bb n - 1 '调用递归函数 maxnum = maxnum - 1 LoopPrint "ok" End SubFunction bb(n As Integer) As String '递归函数 If n < maxnum Then Exit Function bb = bb(n - 1) & "," & combo(n) Print "{" & Mid(bb, 2, Len(bb) - 1) & "}" End Function
aa 6, "{a,b,c,d,e,f}"
End SubSub aa(n As Integer, string1 As String)
ReDim combo(n - 1)
For i = 2 To Len(string1) '分解出各个元素
tempstr = Mid(string1, i, 1)
If tempstr = "}" Then Exit For
If tempstr <> "," Then
combo(j) = combo(j) & tempstr
Else
j = j + 1
End If
Nextbb n - 1 '调用递归函数
Print "ok"
End SubFunction bb(n As Integer) As String '递归函数
If n < 0 Then Exit Function
bb = bb(n - 1) & combo(n)
Print bb
End Function
aa 6, "{a,b,c,d,e,f}" '总的执行函数(传入值)
End SubSub aa(n As Integer, string1 As String)
ReDim combo(n - 1)
For i = 2 To Len(string1) '分解出各个元素
tempstr = Mid(string1, i, 1)
If tempstr = "}" Then Exit For
If tempstr <> "," Then
combo(j) = combo(j) & tempstr
Else
j = j + 1
End If
Next
maxnum = n - 1Do While maxnum >= 0
bb n - 1 '调用递归函数
maxnum = maxnum - 1
LoopPrint "ok"
End SubFunction bb(n As Integer) As String '递归函数
If n < maxnum Then Exit Function
bb = bb(n - 1) & "," & combo(n)
Print "{" & Mid(bb, 2, Len(bb) - 1) & "}"
End Function