Solved

Sorting a List Box Descending  ie Latest to Top

Posted on 2003-11-13
8
336 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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 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
 

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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SLMGR Switches Are Not Working On KMS Host 3 141
vb6 - Transfer from MSHFlexgrid1 to xls issue 8 61
MsgBox 4 71
Excel Automation VBA 19 102
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

756 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