sorting using dir

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Not sure if this is the right place for this question.

I have a list box with the following code to call up files on the harddrive.
strFileName = Dir("M:\Some Folder\another Folder\Another Folder\etc\*.*")

My question is, is there a way I can sort the data? I'd like it to show up
in a descending order instead of ascending.

Thanks in advance for any help/suggestions.
 
Try this:

Dim aFiles()
Dim strFile As String
Dim n As Integer, i As Integer

strFile = Dir("M:\Some Folder\another Folder\Another Folder\etc\*.*")

Do While strFile <> ""
ReDim Preserve aFiles(n)
aFiles(n) = strFile
strFile = Dir()
n = n + 1
Loop

For i = n - 1 To 0 Step -1
Me.lstFiles.AddItem aFiles(i)
Next i

Ken Sheridan
Stafford, England
 
Back
Top