Connecting Tech Pros Worldwide Forums | Help | Site Map

Load files show date modified ?

Newbie
 
Join Date: May 2007
Location: Kosova
Posts: 6
#1: Jan 11 '09
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.  

NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,730
#2: Jan 14 '09

re: Load files show date modified ?


Quote:

Originally Posted by ragazzo View Post

I am using this code to load files
But i have problem when there is a large number of files, ( it shows nothing )

I have no idea why this is the case for you. Can you be clearer as to when this happens?
Quote:

Originally Posted by ragazzo View Post

is it posible to list only files where date modified is today`s date.

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.
Quote:

Originally Posted by ragazzo View Post

Sort by "Modified Date" -Descending

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!
ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,218
#3: Jan 15 '09

re: Load files show date modified ?


Quote:

Originally Posted by ragazzo View Post

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.  

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.  
Reply