Dim a(10), d, x Dim c As Boolean Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Do While Not EOF(1) Line Input #1, x s = 0 For i = 1 To Len(x) b = Mid(x, i, 1) a(i) = b & i d = d & a(i) Next Call abc("") Print #2, List1.ListCount For i = 0 To List1.ListCount Print #2, List1.List(i) Next Loop Close Close End End Sub Sub abc(t) If Len(t) = Len(d) Then c = True For i = 1 To Len(x) t = Replace(t, i, "") Next For i = 0 To List1.ListCount If t = List1.List(i) Then c = False: Exit For Next If c = True Then List1.AddItem t Else For i = 1 To Len(x) If InStr(t, a(i)) = 0 Then Call abc(t & a(i)) Next End If End Sub
Dim a(10), d, x
回覆刪除Dim c As Boolean
Private Sub Form_Load()
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Do While Not EOF(1)
Line Input #1, x
s = 0
For i = 1 To Len(x)
b = Mid(x, i, 1)
a(i) = b & i
d = d & a(i)
Next
Call abc("")
Print #2, List1.ListCount
For i = 0 To List1.ListCount
Print #2, List1.List(i)
Next
Loop
Close
Close
End
End Sub
Sub abc(t)
If Len(t) = Len(d) Then
c = True
For i = 1 To Len(x)
t = Replace(t, i, "")
Next
For i = 0 To List1.ListCount
If t = List1.List(i) Then c = False: Exit For
Next
If c = True Then List1.AddItem t
Else
For i = 1 To Len(x)
If InStr(t, a(i)) = 0 Then Call abc(t & a(i))
Next
End If
End Sub