满意答案
wshaj
推荐于 2018.04.28
采纳率:59% 等级:13
已帮助:9018人
就是比较数值,把大的或小的放在前面
比如,有一个数组a()包含{5,7,3,9,12,15,56}7个数
dim t as integer
for i=0 to a.count-1
for j=i+1 to a.count-1
t=a(i)
if a(i)
a(i)=a(j)
a(j)=t
next
next
这时比较排序法
下面是冒泡排序
Private Sub Form_Load()
Dim a,c As Variant
Dim i As Integer,j As Integer,temp As Integer,bSwap As Boolean
a = Array(17,45,12,80,50)
For j = 0 To UBound(a) - 1
bSwap = False
For i = 0 To UBound(a) - 1
If (a(i) > a(i + 1)) Then '若是递减,改为a(i)