• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 354
  • Last Modified:

Sorting a List Box Descending ie Latest to Top

Is there a simple way of sorting a list box  (DESC).
Ie I need to have the list box sort the latest to the top.
ie
20031212 asasasaas
20031111 m,m,mm,sm,

The option in the list box seems to only allow  sort assending???
0
turnerrob
Asked:
turnerrob
  • 3
  • 3
  • 2
2 Solutions
 
ClothahumpCommented:
Select your recordset in descending order and load the list box that way.
0
 
turnerrobAuthor Commented:
I am loading a directory listing into the list box, ie i do not have a recordset, sorry i did not mention this.
0
 
ClothahumpCommented:
Ok, load the directory listing into an array, sort the array descending, then load the list box.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
bingieCommented:
Here is how to sort an array in descending order

Option Explicit

Private Sub Command1_Click()
   Dim MyArray
   MyArray = Array("A", "Z", "M")
   Call SortDecending(MyArray)
   Debug.Print MyArray(0); MyArray(1); MyArray(2)
End Sub

Private Function SortDecending(a)
   Dim i, j As Long
   Dim tmp
   For i = 1 To UBound(a)
       For j = 0 To UBound(a)
           If LCase(a(i)) > LCase(a(j)) Then
               temp = a(j)
               a(j) = a(i)
               a(i) = temp
           End If
       Next
   Next
   SortDecending = a
End Function

(thx to Erick37 for above)
0
 
turnerrobAuthor Commented:
I thought this may be the only way.!!
Appreciate the advice., thanks for your help

regards turnerrob
0
 
turnerrobAuthor Commented:
Appreciate both the help comments offered.
Have split points, hope this is ok.

regards  turnerrob
0
 
ClothahumpCommented:
Glad to help!
0
 
bingieCommented:
Anytime!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now