有一数组
Mm = Array(1, 3, 4, 3, 5, 1, 20)
如何排序能实现SQL的distinct功能
mm数组找查mm数组的1,3重复数
排序结果为
1,3,4,5,20

解决方案 »

  1.   

    '把数据写入另一个数组中
    temm=mm
    '先排序
    for i=0 to Ubound(Temm)-2
        for j=i+1 to ubound(Temm)-1
            if Temm(i)>Temm(j) then
                tem=Temm(i)
                Temm(i)=Temm(j)
                Temm(j)=tem
            end if
        next
    Next
    '再删除重复数据并将数据置入原数组中。
    for i=0 to Ubound(mm)-1
        mm(i)=0'置0
    next
    i=0
    mm(0)=temm(0)
    for j=1 to ubound(Temm)-1
        if mm(i)<>Temm(j) then
            i=i+1
            mm(i)=Temm(j)
        end if
    next