Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Sorting a List Box Descending  ie Latest to Top

Posted on 2003-11-13
8
Medium Priority
?
349 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 252 total points
ID: 9743050
Ok, load the directory listing into an array, sort the array descending, then load the list box.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Accepted Solution

by:
bingie earned 248 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
 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

782 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