vb怎样判断出程序目录下创建时间为最新的那个文本文件(txt文件)?
第1个回答 2013-03-30
参考一下吧
'工程-引用 “Microsoft Shell Controls And Automation”
Private Sub Command1_Click()
Dim oDLG
Dim pth As String
Dim Flname As String
Dim shl As Shell32.Shell
Dim shfd As Shell32.Folder
Dim s As String
Dim i As Integer
Set oDLG = CreateObject("MSComDlg.CommonDialog")
With oDLG
.DialogTitle = "打开文件"
.Filter = "所有文件|*.*"
.MaxFileSize = 255
.ShowOpen
If .FileName <> "" Then
i = InStrRev(.FileName, "\")
If i = 0 Then Exit Sub
Flname = Mid(.FileName, i + 1)
Set shl = New Shell
Set shfd = shl.NameSpace(Left(.FileName, i - 1))
For i = 0 To 39
If shfd.GetDetailsOf(0, i) <> "" And shfd.GetDetailsOf(shfd.Items.Item(Flname), i) <> "" Then
s = s & i & ":" & shfd.GetDetailsOf(0, i) & ": " & shfd.GetDetailsOf(shfd.Items.Item(Flname), i) & Chr(10)
End If
Next i
MsgBox s, vbInformation, "文件属性"
End If
End With
Set oDLG = Nothing
End Sub追问
'工程-引用 “Microsoft Shell Controls And Automation”
Private Sub Command1_Click()
Dim oDLG
Dim pth As String
Dim Flname As String
Dim shl As Shell32.Shell
Dim shfd As Shell32.Folder
Dim s As String
Dim i As Integer
Set oDLG = CreateObject("MSComDlg.CommonDialog")
With oDLG
.DialogTitle = "打开文件"
.Filter = "所有文件|*.*"
.MaxFileSize = 255
.ShowOpen
If .FileName <> "" Then
i = InStrRev(.FileName, "\")
If i = 0 Then Exit Sub
Flname = Mid(.FileName, i + 1)
Set shl = New Shell
Set shfd = shl.NameSpace(Left(.FileName, i - 1))
For i = 0 To 39
If shfd.GetDetailsOf(0, i) <> "" And shfd.GetDetailsOf(shfd.Items.Item(Flname), i) <> "" Then
s = s & i & ":" & shfd.GetDetailsOf(0, i) & ": " & shfd.GetDetailsOf(shfd.Items.Item(Flname), i) & Chr(10)
End If
Next i
MsgBox s, vbInformation, "文件属性"
End If
End With
Set oDLG = Nothing
End Sub追问
还加什么部件?不打开文件夹行吗?
追答