We Recommend

Visual Basic 2008 Programmer's Reference Visual Basic 2008 Programmer's Reference
Visual Basic Orcas Programmer's Reference is a language tutorial and a reference guide to the upcoming Orcas release of Visual Basic. The tutorial provides basic material suitable for beginners but also includes in-depth content for more advanced developers.


Posted By

eeppeliteloop on 03/23/08


Tagged

sort array arrays


Versions (?)


Sort array


Published in: Visual Basic 


(VB6) Will sort a given array (may sometimes be long).


  1. Public Function SortArray(ByRef TheArray As Variant)
  2. Dim Temp As Variant, X As Integer
  3.  
  4. Sorted = False
  5. Do While Not Sorted
  6. Sorted = True
  7. For X = 0 To UBound(TheArray) - 1
  8. If TheArray(X) > TheArray(X + 1) Then
  9. Temp = TheArray(X + 1)
  10. TheArray(X + 1) = TheArray(X)
  11. TheArray(X) = Temp
  12. Sorted = False
  13. End If
  14. Next X
  15. Loop
  16. End Function

Report this snippet 

You need to login to post a comment.