Solved

Sort Saved Files

Posted on 2002-05-24
4
137 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
[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
  • 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

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!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

726 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