6,868
社区成员




'数组里生成5个不重复的随机数
Sub makeRand()
Dim intTemp As Integer
Dim intRnd(4) As Integer
Dim isSameFlag As Boolean
Dim intCount As Integer
While intCount < 5
intTemp = Int(Rnd() * 10)
isSameFlag = False
For j = 1 To 5
If intRnd(j - 1) = intTemp Then
isSameFlag = True
Exit For
End If
Next
If Not isSameFlag Then
intRnd(intCount) = intTemp
intCount = intCount + 1
End If
Wend
End Sub