Sub x()
Dim arr(1 To 10) As Integer, i, j, k
'产生随机数
For i = LBound(arr) To UBound(arr)
arr(i) = Int(Rnd * 100)
Next i
MsgBox "随机生成的数据是:" & Join(arr, ",")
'排序
For i = LBound(arr) To UBound(arr) - 1
k = i
For j = i + 1 To UBound(arr)
If arr(j) > arr(k) Then k = j
Next j
If k <> i Then
j = arr(k)
arr(k) = arr(i)
arr(i) = j
End If
Next i
'输出
MsgBox "排序之后的数据是:" & Join(arr)
End Sub