VB算法!我要最快递的速度!

来源:百度知道 编辑:UC知道 时间:2024/05/24 06:00:11
我要随机生成100万组36选7的数位,每组七位,把它存在C:\max.txt文件裏!
我要最快递的速度!
thank you!
各位!请说下你们的程序要多久时间!谢谢大家

Private Sub Form_Load()
Open "C:\max.txt" For Output As #1
For i = 1 To 1000000
Print #1, Join(GetRndNotRepeat(1, 36, 7))
Next i
Close #1
End Sub
Public Function GetRndNotRepeat(ByVal NumMin As Integer, ByVal NumMax As Integer, ByVal n As Integer)
Dim arr()
ReDim arr(n - 1)
Dim b() As Boolean
m = NumMax - NumMin
ReDim b(m)
Dim x As Integer
Dim y As Integer
Randomize
For i = 0 To n - 1
Do
x = Int(Rnd * (NumMax - NumMin + 1)) + NumMin
y = x - NumMin
Loop While b(y)
b(y) = True
arr(i) = x
Next i
GetRndNotRepeat = arr
End Function

Option Explicit
Dim I As Long, J As Byte, K As Byte
Dim a(6) As Byte

Private Sub Form_Load()
Form1.AutoRedraw = True
Open "f:\max.txt" For Output As #1
Rando