哪位大虾帮忙编个VB小程序

来源:百度知道 编辑:UC知道 时间:2024/05/06 09:53:40
利用随机函数产生60个100~200之间的随机整数,将其中的偶数按由小到大的顺序排列并输出,将奇数按由大到小的顺序排列并输出。

'排序函数
Private Function PXHS(a() As Integer, n As Integer, b As Boolean)
Dim temp As Integer
For i = 0 To n - 2
For j = i + 1 To n - 1
If b = True Then '由大到小排序
If a(i) < a(j) Then
temp = a(i)
a(i) = a(j)
a(j) = temp
End If
Else
If a(i) > a(j) Then '由小到大排序
temp = a(i)
a(i) = a(j)
a(j) = temp
End If
End If
Next j
Next i
End Function

Private Sub Command1_Click()
Dim a(60) As Integer
Dim intQS(60) As Integer
Dim intOS(60) As Integer
Dim intContQs As Integer
Dim intContOs As Integer
Randomize
For i = 0 To 59
a(i) = Int(100 + 100 * Rnd)
Text1.Text = Text1.Text & CStr(a(i)) & " "
If (a(i) Mod 2) = 0 Then
intOS(intContOs) = a(i)
intContOs = intContOs + 1
Else
intQS(in