Solved

Sorting a List Box Descending  ie Latest to Top

Posted on 2003-11-13
8
327 Views
Last Modified: 2010-05-01
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
Comment
Question by:turnerrob
  • 3
  • 3
  • 2
8 Comments
 
LVL 4

Expert Comment

by:Clothahump
ID: 9743013
Select your recordset in descending order and load the list box that way.
0
 

Author Comment

by:turnerrob
ID: 9743039
I am loading a directory listing into the list box, ie i do not have a recordset, sorry i did not mention this.
0
 
LVL 4

Assisted Solution

by:Clothahump
Clothahump earned 63 total points
ID: 9743050
Ok, load the directory listing into an array, sort the array descending, then load the list box.
0
 
LVL 11

Accepted Solution

by:
bingie earned 62 total points
ID: 9743073
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:turnerrob
ID: 9743079
I thought this may be the only way.!!
Appreciate the advice., thanks for your help

regards turnerrob
0
 

Author Comment

by:turnerrob
ID: 9743124
Appreciate both the help comments offered.
Have split points, hope this is ok.

regards  turnerrob
0
 
LVL 4

Expert Comment

by:Clothahump
ID: 9743150
Glad to help!
0
 
LVL 11

Expert Comment

by:bingie
ID: 9743161
Anytime!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now