Solved

Search and kill the the file..

Posted on 2002-03-20
2
160 Views
Last Modified: 2010-05-02
Hi there,
I’m in a bit of problems and I  have a filelistbox called file1.In that listbox are files called like down here.

---FILELISTBOX---
145320_18-mrt.bck
145637_18-mrt.bck
215825_17-mrt.bck = Formatted as Time 21:58:25 Date _17- march
234226_17-mrt.bck

I need to have a coding to select the oldest file that is (215825_17-mrt.bck) ad the moment and kill it. Do you no how to do this. I need the coding fast plz. Help..

Tanks.
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
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 70 total points
ID: 6882572
Hope you understand this bit of code without explanations:

dim strFile as string
dim datNow as date
dim datOldest as Date
dim datFile as Date

datNow = now()
datOldest = datNow

strFile = dir("c:\yourfiles\*.bck")
while strFile <> empty
  datFile = DateSerial ( year (datnow), Month(datnow), mid( strFile, 8,2))+ TimeSerial ( mid ( strFile, 1,2 ), mid ( strFile, 3,2), mid ( strFile, 5,2 ) )
 
  if datFile < datOldest then
    datOldest = datFile
  end if
  strFile = dir()
wend

if datFile < datNow then
  strFile = "c:\yourfiles\" & Format ( datOldest, "hhnnss\_dd" & -mrt.bck"
  kill strFile
end if

CHeers
0
 

Author Comment

by:pfjvisser
ID: 6882616
Whel tanks angellll.
It worked out with a bit of recoding i had to do. There you points thanks again..
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

732 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