求一个读取某文件文件名代码
请各位VB高手写个代码,该代码可以读取某文件夹里面指定含有关键字的文件名,是xlsx类型的,不显示后缀名 按最新文件日期显示在窗口里的头条,并且用鼠标点击该文件名就可以打开该文件!谢谢!
2022-10-13 21:15
2022-10-13 23:13
程序代码:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_SHOW = 5
Dim sSelFile As String
Dim sdir As String
Private Sub Form_Load()
sSelFile = ""
sdir = "d:\Documents\Desktop\TTTT\"
End Sub
Private Sub Command1_Click()
sFilter$ = "*EE*.xlsx"
sfile$ = Dir(sdir & sFilter)
smin$ = ""
While sfile <> ""
fileTime$ = Format(FileDateTime(sdir & sfile), "YYYYMMDDHHmmss")
If smin < fileTime Then
smin = fileTime
sSelFile = sfile
End If
sfile = Dir()
Wend
inx = InStr(1, sSelFile, ".") - 1
Label1.Caption = Mid$(sSelFile, 1, IIf(inx < 1, Len(sSelFile), inx))
End Sub
Private Sub Label1_DblClick()
If sSelFile = "" Then Exit Sub
ShellExecute Me.hwnd, "open", sdir & sSelFile, 0, sdir, SW_SHOW
End Sub
[此贴子已经被作者于2022-10-14 20:00编辑过]
2022-10-14 10:09
[此贴子已经被作者于2022-10-14 19:33编辑过]

2022-10-14 19:30
<html> <a href="file://C:\Windows">C:\Windows</a> <a href="file://C:\Windows\notepad.exe">C:\Windows\notepad.exe</a> </html>

2022-10-14 19:42
2022-10-14 20:00
2022-10-15 08:59
2022-10-15 09:00
2022-10-15 09:02
2022-10-15 09:34