Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > Working with File Modification Dates
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 16th August 13:09
gary wilkins
External User
 
Posts: 1
Default Working with File Modification Dates



Hello everybody,

I am trying to write a basic form that will allow me to choose a local drive
(local or network-mapped) and display the contents. The basic supposition is
that I am trying to sort the files on the DirList box to be sorted by date
Modified, going furthest back and sorting forward.

As an aside I would like to figure a way to show that files stored that are
over 30 days since last modified will appear in a different color, say red,
or whatever.

I have hit on some elements for DirFile attributes such as ReadOnly or
Archive, but so far the MSDN has been elusive on returning a way to sort by
date once I select a drive letter.

Any suggestions? All assistance greatly appreciated!

Gary
  Reply With Quote


  sponsored links


2 16th August 13:09
noreply
External User
 
Posts: 1
Default Working with File Modification Dates



Hows this?

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vafctFileDateTime.asp

Not sure about the diff colour bit though
  Reply With Quote
3 27th August 08:49
gary wilkins
External User
 
Posts: 1
Default Working with File Modification Dates


Thanks Samuel.

I actually discovered the FileObject.DateLastModified property, which I got
to work with a simple text box and command button. However...read on...

I was using a FileList Box to generate the files, but I think what I really
need to do is to make a List Box with 2 columns (1st is file name, 2nd is
last modified date)
I am trying to populate the list box as such:

NumFiles = File1.ListCount
For I = 0 to NumFiles -1
FileName = File1.Path
List1.AddItem(I) = File1.Path
Next I

However the lineage for the 2nd column escapes me... do I need to do
List1.AddItem for the second colum and enclose it in a Do Until loop?

I'm kind of a newbie here, so the answer might be more obvious than I
realize.

TIA,
Gary


news:<bnjtgn$gsb$1@bob.news.rcn.net>...
  Reply With Quote
4 27th August 08:49
noreply
External User
 
Posts: 1
Default Working with File Modification Dates


My suggestion wouldnt have worked anyway. It was for .NET, oops sorry.

Dont think you can have two columns in a List Box, been a long time
since I've used them. I would suggest using the MSFlexGrid though it
can be a right pain to use.
  Reply With Quote
5 27th August 08:49
martin trump
External User
 
Posts: 1
Default Working with File Modification Dates


In article <c8672b7d.0310281453.e6694d3@posting.google.com> , Samuel Hon
<noreply@samuelhon.co.uk> writes

You can have 2 columns (or more) in a Listbox but they seem to be just a
wrap-around from the first. Try :-

Option ********

Private Sub Form_Load()

Dim i As Long
Show
List1.Columns = 3
For i = 1 To 30
List1.AddItem i
Next i

End Sub

HTH.

Regards

--
Martin Trump
  Reply With Quote
6 27th August 08:49
martin trump
External User
 
Posts: 1
Default Working with File Modification Dates


In article <c8672b7d.0310281453.e6694d3@posting.google.com> , Samuel Hon
<noreply@samuelhon.co.uk> writes


A PS to my previous posting. Seems you need to set List1's columns
property to 1 at design time to make it work.

Regards

--
Martin Trump
  Reply With Quote
7 27th August 19:15
gary wilkins
External User
 
Posts: 1
Default Working with File Modification Dates


Thanks Martin & Samuel:

I did get the list box to work as a 0 columns (I forgot how VB handles
columns in a list box) and this is how I populated it:

Private Sub UpDateList()

Dim NumFiles, FileName, FilePath, FileDate
Dim FileSystemObject, FileObject As Object

NumFiles = File1.ListCount

For I = 0 To NumFiles - 1
FileName = Trim$(File1.List(I))
If Right$(Dir1.Path, 1) = "\" Then
FilePath = File1.Path & FileName
Else
FilePath = File1.Path & "\" & FileName
End If
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
Set FileObject = FileSystemObject.GetFile(FilePath)
FileDate = Trim$(FileObject.DateLastModified) Temp = Space$(31)
If Len(FileName) > 20 Then
FileName = Left$(FileName, 17) & "..."
End If
Mid$(Temp, 1) = FileName
Mid$(Temp, 22) = FileDate
List1.AddItem (Temp)
Next I


End Sub

The number of the columns causes a wraparound... and I also got the dates to
display with the Mid$ function, although some longer ones were getting
truncated so I had to set Temp = Space$(31) instead of 30 as originally
planned.

Now I'm off to figure out how to delete them from the list and from the
device in question. The code I used to take the List1.Selected property is
squawking at me that it's an invalid procedure call.

Gary
  Reply With Quote
8 27th August 19:15
randy birch
External User
 
Posts: 1
Default Working with File Modification Dates


You can create the appearance of columns in a lisbox using the API with
LB_SETTABSTOPS, then use vbTab to separate the elements of the line to align
at the different columns. If a column's width exceeds the tabstop width set
you're still screwed as far as alignment of that line is concerned, so if
this is expected to be the case, perhaps a listview control in report view
would be more appropriate as the data interface. That would provide you the
means to also sort the data by date or any other column added to the
listview.

Here's the basics on creating and using tab stops in a normal list box ...
http://www.mvps.org/vbnet/code/listapi/listboxtabs.htm ... and this helps
design the positions ... http://www.mvps.org/vbnet/code/listapi/cooltabs.htm

--

Randy Birch
MVP Visual Basic
http://www.mvps.org/vbnet/
Please respond only to the newsgroups so all can benefit.


: Thanks Samuel.
:
: I actually discovered the FileObject.DateLastModified property, which I
got
: to work with a simple text box and command button. However...read on...
:
: I was using a FileList Box to generate the files, but I think what I
really
: need to do is to make a List Box with 2 columns (1st is file name, 2nd is
: last modified date)
: I am trying to populate the list box as such:
:
: NumFiles = File1.ListCount
: For I = 0 to NumFiles -1
: FileName = File1.Path
: List1.AddItem(I) = File1.Path
: Next I
:
: However the lineage for the 2nd column escapes me... do I need to do
: List1.AddItem for the second colum and enclose it in a Do Until loop?
:
: I'm kind of a newbie here, so the answer might be more obvious than I
: realize.
:
: TIA,
: Gary : : :
: "Samuel Hon" <noreply@samuelhon.co.uk> wrote in message : news:c8672b7d.0310271440.76da96ef@posting.google.c om...
: > Hows this?
: >
: >
: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/ : vafctFileDateTime.asp
: >
: > Not sure about the diff colour bit though
: >
: > "Gary Wilkins" <gwilkins@#NOSPAM#vtiboston.com> wrote in message
: news:<bnjtgn$gsb$1@bob.news.rcn.net>...
: > > Hello everybody,
: > >
: > > I am trying to write a basic form that will allow me to choose a local : drive
: > > (local or network-mapped) and display the contents. The basic : supposition is
: > > that I am trying to sort the files on the DirList box to be sorted by : date
: > > Modified, going furthest back and sorting forward.
: > >
: > > As an aside I would like to figure a way to show that files stored that : are
: > > over 30 days since last modified will appear in a different color, say : red,
: > > or whatever.
: > >
: > > I have hit on some elements for DirFile attributes such as ReadOnly or
: > > Archive, but so far the MSDN has been elusive on returning a way to sort : by
: > > date once I select a drive letter.
: > >
: > > Any suggestions? All assistance greatly appreciated!
: > >
: > > Gary
:
:
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666