vb:编写一程序 产生10个100~200间的随机整数将其中的偶数按由小到大的排序排列并输出

再将其奇数按由小到大大的顺序排列并输出

这个很简单的啊
我就给你说说产生随机数的 rnd 产生的是0或者1
产生100-200之间的随机数
rnd(100-200-1)+200
温馨提示:答案为网友推荐,仅供参考
第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