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
Solved

Search and kill the the file..

Posted on 2002-03-20
2
156 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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Problem to skip loop 6 64
Adding to a VBA? 6 78
Problem to With line 4 63
Set email body to html using vbscript 6 49
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

860 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