Solved

Sort Saved Files

Posted on 2002-05-24
4
134 Views
Last Modified: 2010-05-02
I have a routine that saves files to a directory in numbered order:
pjt1.dat
pjt2.dat
'''
'''
pjt10.dat
pjt11.dat

The problem is this: when sorted they show like this:
pjt1.dat
pjt10.dat
pjt11.dat
pjt2.dat
I need to rename these files to load in the order they happened...or sort by date modified...
Is there any way out of this?
Thanks

0
Comment
Question by:Object_shun
  • 2
4 Comments
 
LVL 22

Expert Comment

by:rspahitz
ID: 7033310
Click on the Data modified column header in Windows explorer.

Where are these files being display?  How are they being created?  You can rename them so that each 1-digit number has a leading zero and that would help...

In code, you can do this to add the zero "prefix" before the digit:

dim strFilename as string

strFilename = dir$(WhateverPath & "pjt?.dat"
while strFilename <> vbnullstring
  name strFilename as left$(strFilename ,3) & "0" & mid$(strFilename ,4)
  strFilename = dir$
wend
0
 

Author Comment

by:Object_shun
ID: 7033315
Im loading them(filenames) to a sorted listbox...loading the filename from the list...to view in order.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7033321
Hearing...
0
 
LVL 22

Accepted Solution

by:
rspahitz earned 100 total points
ID: 7033439
Obj, sorted listboxes always sort alphabetically, and unless the filenames are changes to add the "leading zero" they won't sort correctly.  Another choice is to une a non-sorted listbox.  From that, if you add the items in sequence, they will be "sorted" according to when they are added.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SSRS expression Issue finding a string 10 91
Copy a row 12 64
VBA - If Bookmark = "XXBOOKMARKXX" then 15 41
VB script to continue despite error 2 16
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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

828 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