求vb程序:从数字1-20中随机选取不重复的10个,并输出?

来源:百度知道 编辑:UC知道 时间:2024/06/23 09:01:07
求vb程序:从数字1-20中随机选取不重复的10个,并输出?
从数字1-20中随机选取不重复的10个,并输出在列表框中
谢谢

Dim a As Integer

Private Sub Command1_Click()
Randomize
For i = 1 To 10
a = Int((Rnd * 20) + 1)
List1.AddItem a
Next
End Sub

Private Sub Form_Load()
Form1.AutoRedraw = True
Randomize
For i = 1 To 10
a = Int((Rnd * 20) + 1)
Print a;
Next
End Sub

Dim a As Integer
Randomize
For i=1 To 10
a=Int(Rnd*19+1)
Print a;
Next i