第1个回答 2008-05-18
设执行按钮为Command1,结果输出到Form1上。
请建立2个ListBox,设为List1, List2。
在开发环境下设置List1和List2的Sorted属性为True(不能写在代码中)。代码如下。
--------------------------------
Dim a(9) As Integer, i As Integer
Private Sub Command1_Click()
Randomize
For i = 0 To 9
a(i) = Rnd() * 100 + 100
If a(i) Mod 2 = 0 Then
List1.AddItem (a(i))
Else
List2.AddItem (a(i))
End If
Next
For i = 0 To List1.ListCount - 1
Print List1.List(i)
Next
For i = 0 To List2.ListCount - 1
Print List2.List(i)
Next
End Sub