用前面我那个魔方阵程序改的,希望你能看懂.
生成了数据文件,非常抱歉的我不能发出来.超过了 100M
达到了: 107 MB (112,492,800 字节)
数据文件,正常的话,一般在 VB6 的安装目录里面.
------------------运行结果--------------------------------
共 3628800 组结果
--------------------窗体说明------------------------------
一个文本框,一个标签,一个按钮
--------------------代码如下-------------------------------
Option Explicit
Private Sub Command1_Click()
Dim a As Long, b As Long, c As Long, d As Long
Dim e As Long, f As Long, g As Long, h As Long, i As Long
Dim j As Long
Dim k As Long, m As Long
Dim n(1 To 10) As Long
Dim p As String
Open "test.txt" For Output As #1
p = ""
'9个循环变量
For a = 1 To 10
n(1) = a
For b = 1 To 10
n(2) = b
If Not IS重复(2, n()) Then
'测试是否重复
For c = 1 To 10
n(3) = c
If Not IS重复(3, n()) Then
'测试是否重复
For d = 1 To 10
Label1.Caption = a & "
" & b & "
" & c & "
" & d
'进度
DoEvents
n(4) = d
If Not IS重复(4, n()) Then
'测试是否重复
For e = 1 To 10
n(5) = e
If Not IS重复(5, n()) Then
'测试是否重复
For f = 1 To 10
n(6) = f
If Not IS重复(6, n()) Then
'测试是否重复
For g = 1 To 10
n(7) = g
If Not IS重复(7, n()) Then
'测试是否重复
For h = 1 To 10
n(8) = h
If Not IS重复(8, n()) Then
'测试是否重复
For i = 1 To 10
n(9) = i
If Not IS重复(9, n()) Then
'测试是否重复
For j = 1 To 10
n(10) = j
If Not IS重复(10, n()) Then
'测试是否重复
m = m + 1
'计数
Print #1, a & "
" & b & "
" & c & "
" & d & "
" & e & _
"
" & f & "
" & g & "
" & h & "
" & i & "
" & j
'把结果放到文本框中
'p = p & a & " " & b & " " & c & " "
'p = p & d & " " & e & " " & f & " "
'p = p & g & " " & h & " " & i & " "
'p = p & j & vbCrLf
'Text1.Text = p
'DoEvents
End If
Next j
End If
Next i
End If
Next h
End If
Next g
End If
Next f
End If
Next e
End If
Next d
End If
Next c
End If
Next b
Next a
Close #1
p = p & vbCrLf
p = p & "共 " & m & " 组结果"
Text1.Text = p
MsgBox "共 " & m & " 组结果"
End Sub
Public Function IS重复(cs As Long, n() As Long) As Boolean
Dim o1 As Long
'初始化为不重复
IS重复 = False
'查找最后一个数据是否与前面的数据相同
For o1 = 1 To cs - 1
If n(o1) = n(cs) Then
'找到相同,
IS重复 = True
'重复了
Exit For
End If
Next o1
End Function