Reputation: 4359
I'm working with some legacy VB6 code and I'm horrible with it. The code below "thinks" its getting the most recent file by using the name of the file. But this method no longer works because it uses digits 0 - 9 to determine this. And it sees 6 as being newer than 2, where that number is the year. For example. the files that need sorting are formatted like this.
FORMZZ6.eln is a 2006 file
FORMZZ2.eln is a 2012 file
The code below sorts alphabetically. Is it possible to choose the file nased on its last modified date?
Private Function ResolveFormVersion(sForm As String) As String
Dim sFile As String
Dim sFile2 As String
sFile = Dir(BaseDirectory & sForm, vbNormal)
Do
sFile2 = Dir
If sFile2 > sFile Then sFile = sFile2
Loop Until sFile2 = ""
ResolveFormVersion = sFile
End Function
Thanks
Upvotes: 0
Views: 1543
Reputation: 801
Yes you should be able to rewrite the loop to use the FileDateTime function:
http://msdn.microsoft.com/en-us/library/aa262740%28VS.60%29.aspx
Upvotes: 3