[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Sort Saved Files

Posted on 2002-05-24
4
Medium Priority
?
141 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 400 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…
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…
Suggested Courses

656 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