求一个vb程序,随机十个数字!按一个按钮正序排列,按另一个按钮倒序排列
1个回答
2014-12-10
展开全部
Dim a(1 To 10) As Integer
Private Sub Command1_Click() '产生随机数
Randomize
For i = 1 To 10
a(i) = Int(Rnd * 90 + 10)
Print a(i);
Next i
End Sub
Private Sub Command2_Click() '正序排列
For i = 1 To 9
For j = i + 1 To 10
If a(i) > a(j) Then b = a(i): a(i) = a(j): a(j) = b
Next j
Next i
For i = 1 To 10
Print a(i);
Next i
End Sub
Private Sub Command3_Click() '倒序排列
For i = 1 To 9
For j = i + 1 To 10
If a(i) < a(j) Then b = a(i): a(i) = a(j): a(j) = b
Next j
Next i
For i = 1 To 10
Print a(i);
Next i
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询