By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,495 Members | 1,146 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,495 IT Pros & Developers. It's quick & easy.

Load files show date modified ?

P: 6
I am using this code to load files
But i have problem when there is a large number of files, ( it shows nothing )
is it posible to list only files where date modified is today`s date.
And show in List "Modified Date" too.
Sort by "Modified Date" -Descending
Thank You
Code used
Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Form_Load()
  3. Dim LoadFiles   As String
  4. Dim strFill     As String
  5. LoadFiles = dir$("c:\test\*.txt", vbbHidden Or vbSystem)
  6. Do While LoadFiles > ""
  7. strFill = strFill & LoadFiles & ";"
  8. LoadFiles = dir$
  9. Loop
  10. lstFiles.RowSource = strFill
  11. End Sub 
  12.  
Jan 11 '09 #1
Share this Question
Share on Google+
2 Replies


NeoPa
Expert Mod 15k+
P: 31,186
@ragazzo
I have no idea why this is the case for you. Can you be clearer as to when this happens?
@ragazzo
I'm pretty sure not I'm afraid. The search string and the attributes are the only ways I could find to specify what you want returned.
@ragazzo
Another "No" again I'm afraid.

You can load them into an array and sort them there of course, but as you only have the name at this stage it can only really be done alphabetically.

Sorry I could be no more help and welcome to Bytes!
Jan 14 '09 #2

ADezii
Expert 5K+
P: 8,597
@ragazzo
I cleaned the code up for you a little, this should work:
Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim strLoadFiles As String
  3. Dim strFill As String
  4. '
  5. 'Good idea to specifically set the Row Source Type
  6. Me![lstFiles].RowSourceType = "Value List"
  7. '
  8. 'strLoadFiles = Dir$("C:\Test\*.txt")       'Normal Attribute Files
  9. '
  10. 'Why would a *.txt File have the Hidden or System Attribute?
  11. strLoadFiles = Dir$("C:\Test\*.txt", vbHidden Or vbSystem)
  12. '
  13. Do While strLoadFiles <> ""
  14.   If CDate(Format$(FileDateTime("C:\Test\" & strLoadFiles), "mm/dd/yyyy")) = Date Then
  15.     strFill = strFill & strLoadFiles & ";"
  16.   End If
  17.   strLoadFiles = Dir$
  18. Loop
  19. '
  20. 'Remove Trailing Semi-Colon
  21. lstFiles.RowSource = Left$(strFill, Len(strFill) - 1)
  22. End Sub
  23.  
Jan 15 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.