'在窗体上增加控件command1,label1,然后复制以下代码
Option Explicit
Dim a(9) As Long
Private Sub Command1_Click()
Dim i As Long, l As Long, n As Long
Dim j As Long, s As String
For i = 0 To 9 '使用选择排序法排序,每次选择最小的数值。
For l = i To 9
If a(i) > a(l) Then
n = a(i)
a(i) = a(l)
a(l) = n
End If
Next l
Print a(i)
s = ""
For j = 0 To 9
s = s & a(j) & vbNewLine
Next
MsgBox s, vbInformation, "阶段排序情况"
Next i
End Sub
Private Sub Form_Load()
a(0) = 564 '给数组a中个数组元素赋值。
a(1) = 78
a(2) = 45
a(3) = 456412
a(4) = 456
a(5) = 1
a(6) = 45 + 79
a(7) = 12
a(8) = 1 * 966
a(9) = 65 / 5
Dim i As Long
For i = 0 To 9
Label1.Caption = Label1.Caption & "第" & CStr(i + 1) & "是:" & CStr(a(i)) & " "
Next i
End Sub