Solved

Sort Saved Files

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Window placement 17 74
VB 6.0 printer how to align 6 57
using Access 8 58
Can we place a tooltip on the actual vb6 form 5 35
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

932 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

10 Experts available now in Live!

Get 1:1 Help Now