Dim LOGS() As Integer
Dim lngLogCount As Long
Private Sub Command1_Click() Dim intRnd As Integer
ReDim Preserve LOGS(lngLogCount)
Randomize
intRnd = Int(Rnd() * 91 + 10)
LOGS(lngLogCount) = intRnd
For i = lngLogCount - 1 To 0 Step -1
If LOGS(i) = intRnd Then
LOGS(i) = -1
Exit For
End If
Next
lngLogCount = lngLogCount + 1
End SubPrivate Sub Command2_Click()
List1.Clear
For i = 0 To lngLogCount - 1
List1.AddItem LOGS(i)
Next
End Sub
Dim lngLogCount As Long
Private Sub Command1_Click() Dim intRnd As Integer
ReDim Preserve LOGS(lngLogCount)
Randomize
intRnd = Int(Rnd() * 91 + 10)
LOGS(lngLogCount) = intRnd
For i = lngLogCount - 1 To 0 Step -1
If LOGS(i) = intRnd Then
LOGS(i) = -1
Exit For
End If
Next
lngLogCount = lngLogCount + 1
End SubPrivate Sub Command2_Click()
List1.Clear
For i = 0 To lngLogCount - 1
List1.AddItem LOGS(i)
Next
End Sub
1.没必要定义lngLogCount呀,用Ubound()函数不就结了?
2.再给一个取随机数的函数:
Public Function GetRnd(lMin As Long, lMax As Long) As Long
Dim I As Long
GetRnd = (lMax - lMin + 1) * Rnd + 1
End Function