Tuesday, July 31, 2012

Sort Array elements


Dim oArray
Dim oCounter1
Dim oCounter2
Dim tmp

oArray=array(8,3,4,2,7,1,6,9,5,0)
For oCounter1=lbound(oArray) to ubound(oArray)
        For oCounter2=lbound(oArray) to ubound(oArray)-1
                    If oArray(oCounter2)>oArray(oCounter2+1) Then
                        tmp=oArray(oCounter2)
                      oArray(oCounter2)=oArray(oCounter2+1)
                        oArray(oCounter2+1)=tmp
                    End If       
    Next  
Next

For oCounter1=lbound(oArray) to ubound(oArray)
    oTemp = oTemp & oArray(oCounter1)
Next
msgbox oTemp

No comments:

Post a Comment