Const n = 10
Dim d(n) As Integer, c As Integer
Private Sub Form_Load()
Dim i As Integer, j As Integer, f As Boolean, s As String
Randomize
c = n
For i = 1 To n
f = False
d(i) = ① ' 随机生成个位数为“9”的两位数
For j = 1 To i - 1
If ② Then f = True
Next j
If f Then c = c - 1
Next i
'原始数据在文本框Text1中显示。代码略
End Sub
Private Sub Command1_Click()
Dim i As Integer, j As Integer, k As Integer, m As Integer
Dim cnt As Integer,t As String, s As String
d(0) = 100
cnt = Val(Text2.Text)
If cnt > c Then
Text3.Text = "输入筛选的个数太大,请重新输入!"
Exit Sub 'Exit Sub表示退出过程
End If
For i = 1 To cnt
k = i
For j = i + 1 To n
If d(j) < d(i - 1) And ( ) Then k = j
Next j
If k <> i Then
t = d(i): d(i) = d(k): d(k) = t
End If
Next i
For i = 1 To cnt
s = s + Str(d(i)) + ","
Next i
Text3.Text = ③
End Sub
① ② ③