Solved

FILE LIST BOXES TO SHOW FILES CREATED AFTER A CERTAIN DATE

Posted on 2003-11-17
13
454 Views
Last Modified: 2010-05-01
I have a File List in my VB program called File1 and i have set it to show only files with extension .IDX

Unfortunatly, it brings up ALL files in that folder with that extension and I only want it to show files that have been created from 1 month ago to the present date.  Is there anyway this can be done?
0
Comment
Question by:ian1delap
  • 4
  • 4
  • 2
  • +2
13 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 9764492
Nope.  You will have to define your own custom dialog box.

Anthony
0
 
LVL 1

Author Comment

by:ian1delap
ID: 9764918
This is a completly automated program that runs overnight so I dont want any message boxes or anything of the sort to interrupt the program.
0
 
LVL 9

Expert Comment

by:Dang123
ID: 9765167
ian1delap,
    You will need to make your own list. You can use the Dir() function to list the files and this link to check the file creation dates to decide if you want to work on the file or not.


http://www.geocities.com/SiliconValley/Lakes/6445/vb/025.html

Dang123

0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 9765180
Than there is no need for a Form, alone a File List control or any controls for that matter.  You can put everything in a module and get your files in one of the following ways:

1. Using the File System Object.
2. Using the DIR function.

You will then need to filter out based on the extension and date.

Anthony
0
 
LVL 14

Expert Comment

by:aelatik
ID: 9765993
Put a listbox on your form and paste the following code :

Function SetList(Directory, Extension, Startdate As Date, EndDate As Date)
    Dim X
        X = Dir(Directory & Extension)
        While X <> ""
                If FileDateTime(Directory & X) > Startdate And FileDateTime(Directory & X) < EndDate Then
                        List1.AddItem X
                End If
            X = Dir()
        Wend
       
End Function

Private Sub Form_Load()
    SetList "c:\winnt\", "*.idx", Date - 30, Date
End Sub
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 9768144
Again, if this is an automated program and there is no interface then there is no need for a form, let alone controls on the form.  If you need code to do this let me know.

Anthony
0
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.

 
LVL 1

Author Comment

by:ian1delap
ID: 9777371
aelatik,
I have tried your code and it brings up no errors, it also doesnt bring up any files either.  That is the sort of idea I'm looking for though.
0
 
LVL 1

Author Comment

by:ian1delap
ID: 9777422
This may help a bit:

The program is designed to search for two different bits of text in each file and extract certain numbers from those files.

The program then goes through the files again searching for two other bits of text and again extracts ceratin text from those files.

It repeats this process several times, and in the end prints off a report of what it has NOT found.

The only problem is that it takes far too long to complete and it searches through every single file whereas, as explained above, I only want to check files from a month ago to the present date.

cheers
0
 
LVL 9

Expert Comment

by:Dang123
ID: 9779548
ian1delap,
    You could pick up a lot of speed by reading the files once and doing all your checking while you have the information in memory. And as I suggested above, using the Dir() would limit the file types. Thanks aelatik for pointing out FileDateTime to limit file age, I was not aware of that function, it would be easier that what my link suggested.

    The code posted by aelatik works fine for me. Keep in mind that as posted it looks in the "c:\winnt\" directory and files created after 00:00 in the morning are excluded (Date + Time in the call would make it to current time)

Dang123
0
 
LVL 1

Author Comment

by:ian1delap
ID: 9781646
I worked something out

It doesnt exclude any files, which in the long run, is a good thing, but it excludes searching those files.  I used the FileDateTime function which I already had in place and I used

If FileDateTime(details) < Now - 30 Then File1.ListIndex = File1.ListIndex + 1

Thanks for all your help anyway
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 9784339
Then please close this question.  Here is how:

Request a refund because you answered your own question (Refund/PAQ)
http://www.experts-exchange.com/help/closing.jsp#4

Thanks,
Anthony
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 9806105
PAQed, with points refunded (100)

Computer101
E-E Admin
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
vb6 programatically bring window to front 8 63
Excel object stays open 19 70
SLMGR Switches Are Not Working On KMS Host 3 63
Hide vba in gp 7 79
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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 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…

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

15 Experts available now in Live!

Get 1:1 Help Now