Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

FileListBox Question

Posted on 2002-03-19
7
Medium Priority
?
302 Views
Last Modified: 2010-05-02
Hi there,
I need help with a filelistbox and i hope there is a sample for me out there. I need to no how to find
the oldest file in the list.
--------------------------------------
I have a listbox with files like here.
Every filename is : Hmmss_D-mmm.bck

145320_18-mrt.bck
145637_18-mrt.bck
215825_17-mrt.bck
234226_17-mrt.bck
---------------------------------------
I no that the file "215825_17-mrt.bck" is the oldest but is there a VB code to find the oldest file.
I have a timer to kill the oldest so that is wy i need it.

Sorry my englesh is not so good but i try.

Thanks..
Patrick Visser..
0
Comment
Question by:pfjvisser
[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
  • 4
  • 3
7 Comments
 
LVL 1

Expert Comment

by:Doodle
ID: 6879408
the FileDateTime(path) function will return the date of the files. Check them all work and then delete the oldest using the kill command.

Or yu could used th file system object [Microsoft Scripting Runtime]

Hope this helps

0
 

Author Comment

by:pfjvisser
ID: 6879479
Thanks, but do you have a sample code for me plz.
I appr. it.
0
 
LVL 1

Expert Comment

by:Doodle
ID: 6879508
Dim iCounter as integer
Dim dMinDate as date
Dim iOldestFileIndex as integer

For iCounter = 0 to LstFiles.ListCount-1
   if datediff("s",dMinDate,FileDateTime(LstFiles.List(iCounter)) > 0 then
       dmindate = filedatetime(lstfiles.list(iCounter)
       iOldestFileIndex = iCoutner
   end if
next
kill lstfiles.list(icounter)

This is assuming you are using a listbox with the files full path in the list. Havent tested the code so there could be a few buggs, but im sure you can work them out.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:pfjvisser
ID: 6879785
Whel i'm happy that you send the sample code doodle,
but i 'm using a file listbox. Can you send it with the coding of the file listbox plz..
0
 
LVL 1

Accepted Solution

by:
Doodle earned 210 total points
ID: 6882063
Dim iCounter as integer
Dim dMinDate as date
Dim iOldestFileIndex as integer

For iCounter = 0 to File1.ListCount-1
  if datediff("s",dMinDate,FileDateTime(file1.path & "\" & File1.List(iCounter)) > 0 then
      dmindate = filedatetime(file1.path & "\" & File1.list(iCounter)
      iOldestFileIndex = iCoutner
  end if
next
kill file1.path & "\" File1.list(icounter)

0
 

Author Comment

by:pfjvisser
ID: 6882096
Yha i did recoded it the same as you yesterday but thanks an. Whel here are your points so thaks for helping me out oke.
0
 

Author Comment

by:pfjvisser
ID: 6882099
Yha i did recoded it the same as you yesterday but thanks an. Whel here are your points so thaks for helping me out oke
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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

604 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