Option Explicit
Const K = 10
Private Sub Command1_Click()
Dim num As Integer
Dim n As Integer
Dim m As Integer
Dim a() As Integer
Text1.Text = ""
If IsNumeric(Text2.Text) = False Then MsgBox "请输入数值!", 48, "警告1": Text2.Text = "": Exit Sub
num = Int(Val(Text2.Text))
If num > 100 Or num <= 0 Then MsgBox "请输入100以内的正整数!", 48, "警告2": Text2.Text = "": Exit Sub
ReDim a(num - 1)
For n = 0 To num - 1
Q:
a(n) = Int(Rnd * 100)
If n <> 0 Then
For m = 0 To n - 1
If a(n) = a(m) Then GoTo Q
Next m
End If
If (n + 1) Mod K <> 0 Then
Text1.Text = Text1.Text + Format(CStr(a(n)), "00") + " "
Else
Text1.Text = Text1.Text + Format(CStr(a(n)), "00") + Chr(13) + Chr(10)
End If
Next n
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Randomize Timer
Command1.Caption = "开始"
Command2.Caption = "清除"
Command3.Caption = "退出"
End Sub