2012-11-09 46 views
0

我正在處理一些傳統的VB6代碼,我對此感到厭煩。下面的代碼「認爲」它使用文件的名稱獲取最近的文件。但是這種方法不再有效,因爲它使用數字0-9來確定它。它認爲6比2更新,這個數字是年份。例如。需要排序的文件格式如下。如何獲取VB6文件夾中最近過期的文件

FORMZZ6.eln is a 2006 file 
FORMZZ2.eln is a 2012 file 

下面的代碼按字母順序排列。是否有可能在最後修改日期選擇文件?

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 

感謝

回答

相關問題