在vb的list里生成20个两位数的随机数后,怎样将生成的随机数中的偶数删除,
问题描述:
在vb的list里生成20个两位数的随机数后,怎样将生成的随机数中的偶数删除,
答
'界面上 放一个 按钮,一个list框
Option Explicit
Private Sub cmdCommand1_Click()
Dim i As Integer,j As Integer
j = List1.ListCount - 1
Do While i If List1.List(i) Mod 2 = 0 Then
List1.RemoveItem i
i = 0
Else
i = i + 1
End If
j = List1.ListCount - 1
Loop
End Sub
Private Sub Form_Load()
Dim i As Integer
Randomize
For i = 1 To 20
List1.AddItem CInt(Rnd * 89) + 10
Next
End Sub