Private Function DeQuy(intSN As Integer,
intEN As Integer,
intSP As Integer,
intEP As Integer,
ParamArray Chuoi() As String) As String
If intSN = intSP = intEP = intEN And intSN = 0 Then
DeQuy = ""
intSN = 1
intEN = 1
intSP = 1
intEP = Chuoi.Length
DeQuy = Chuoi(intSP - 1) + Chuoi(intSN - 1) + Chuoi(intEN - 1) + ";"
intEN += 1
DeQuy += DeQuy(intSN, intEN, intSP, intEP, Chuoi)
Return DeQuy
End If
If intEN > intEP Then
intEN = 1
intSN += 1
If intSN > intEP Then
intSN = 1
intSP += 1
If intSP > intEP Then
Exit Function
End If
End If
ElseIf (intEN = intEP = intSN = intEP) And (intSP = Chuoi.Length) Then
Exit Function
End If
DeQuy += Chuoi(intSP - 1) + Chuoi(intSN - 1) + Chuoi(intEN - 1) + ";"
intEN += 1
DeQuy += DeQuy(intSN, intEN, intSP, intEP, Chuoi)
End Function
Private Sub Main()
Dim Chuoi As String
Chuoi = DeQuy(0, 0, 0, 0, "a", "b", "c")
End Sub