Option Explicit
Dim arr() As String
Function CreateRnd(Length As Long) As String
Dim i As Long, r As Integer
For i = 1 To Length
r = Rnd * 9
CreateRnd = CreateRnd & CStr(r)
Next
End Function
Private Sub cmdCancel_Click()
End
End Sub
Private Sub cmdG_Click()
Dim i As Long, c As Long, s As String, out As String, all As Long, l As Long
Randomize
all = CInt(txtC.Text) - 1
l = CInt(txtLen.Text)
ReDim arr(all)
Open txtPath.Text For Output As #1
If chkRepeat.Value = vbChecked Then
Do
s = CreateRnd(l)
For i = 0 To c - 1
If arr(i) = s Then Exit For
Next
If i = c Then
arr(c) = s
c = c + 1
Print #1, s
End If
SetS CStr(c + 1) & "/" & CStr(all + 1)
Loop Until c = all
Else
Do
s = CreateRnd(l)
arr(c) = s
c = c + 1
Print #1, s
SetS CStr(c + 1) & "/" & CStr(all + 1)
Loop Until c = all
End If
Close #1
SetS "保存完毕!"
End Sub
Private Sub cmdView_Click()
cd.Filter = "文本文件(*.txt)|*.txt|所有文件|*.*"
cd.ShowSave
txtPath.Text = cd.FileName
End Sub
Sub SetS(s As String)
lblState.Caption = s
DoEvents
End Sub
Private Sub txtPath_Change()
If Len(txtPath.Text) > 0 Then cmdG.Enabled = True
End Sub下载本文