前端之家收集整理的这篇文章主要介绍了
对数组进行排序,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
下面是一个对数组进行排序的样例程序。 Function sort_arr(arr As Variant) As Variant Dim Temp As Variant,i As Long For i = 0 To UBound(arr) If i <> 0 Then If arr(i) < arr(i - 1) Then Temp = arr(i) arr(i) = arr(i - 1) arr(i - 1) = Temp i = i - 2 '×¢ÒâÕâÒ»¾ä If i < 0 Then i = 0 End If End If Next '********************************** sort_arr = arr End Function
调用程序: Sub test() Dim ss_arr(4) As Variant ss_arr(0) = 123 ss_arr(1) = 485 ss_arr(2) = 435 ss_arr(3) = 142 ss_arr(4) = 21 Dim result() As Variant result = sort_arr(ss_arr) End Sub
原文链接:https://www.f2er.com/vb/259341.html