我需要在给定目录中找到具有最新日期的文件。我不是VB6 的初学者,这就是我需要用于一些旧代码的东西。在下面整天杀死谷歌之后,我到目前为止所拥有的。但它没有找到正确的文件。有人可以帮忙吗?谢谢
Dim sFile1 As String
Dim sFile2 As String
Dim dFile1Date As Date
Dim dFile2Date As Date
sFile1 = Dir("c:\test\*.*", vbNormal)
Do
sFile2 = Dir
If sFile1 <> "" Then dFile1Date = FileDateTime("c:\test\" & sFile1)
If sFile2 <> "" Then dFile2Date = FileDateTime("c:\test\" & sFile2)
If dFile1Date > dFile2Date Then sFile2 = sFile1
Loop Until sFile2 = ""
FormVersionDate = sFile1
Call MsgBox(FormVersionDate, vbExclamation, App.Title)