VB数组题 有10个数放入数组中求其最大数及所在的下标
展开全部
控件要求:
两个listbox,两个command,如图所示:
Dim a(1 To 10) As Integer
Private Sub Command1_Click()
Dim i As Integer
For i = 1 To 10
Randomize
a(i) = Int(Rnd * 89) + 10
List1.AddItem a(i)
Next
End Sub
Private Sub Command2_Click()
Dim i As Integer, j As Integer
For i = 1 To 9
For j = 1 To 9
If a(j) > a(j + 1) Then
t = a(j): a(j) = a(j + 1): a(j + 1) = t
End If
Next
Next
For i = 1 To 10
List2.AddItem a(i)
Next
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询