Solved

Sort Saved Files

Posted on 2002-05-24
4
131 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
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.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now