'Auteur: Alain PROVISTE
Option Base 1
Private Sub AnnaGramme(mot As String, ByRef tablo() As String)
Dim longueur As Byte
Dim i As Byte
Dim l As Double
Dim k As Byte
Dim j As Double
Dim motTab() As String * 1
Dim annaTab() As String
Dim tempmot As String
Dim temptab() As String
Dim lenTab As Double
Dim pos As Double
Dim Find As Boolean
longueur = Len(mot)
If longueur = 1 Then
ReDim tablo(1)
tablo(1) = mot
Exit Sub
End If
ReDim motTab(longueur)
For i = 1 To longueur
motTab(i) = Mid(mot, i, 1)
Next i
lenTab = Fac(longueur)
ReDim annaTab(lenTab)
For i = 1 To longueur
tempmot = vbNullString
Find = False
For k = 1 To longueur
If Find Then
tempmot = tempmot & motTab(k)
Else
If motTab(k) = motTab(i) Then
Find = True
Else
tempmot = tempmot & motTab(k)
End If
End If
Next k
If Len(tempmot) = 1 Then
ReDim temptab(1)
temptab(1) = tempmot
Else
Call AnnaGramme(tempmot, temptab())
End If
For j = 1 To lenTab / longueur
For l = 1 To UBound(temptab())
annaTab(l + pos) = motTab(i) & temptab(l)
Next l
DoEvents
Next j
pos = pos + lenTab / longueur
Next i
tablo() = annaTab()
End Sub
Private Function Fac(Number As Byte) As Double
Dim i As Byte
Dim a As Double
a = 1
For i = 1 To Number
a = a * i
Next i
Fac = a
End Function