code291a.txt
来自「VB大全(精华版)源代码」· 文本 代码 · 共 40 行
TXT
40 行
Option Explicit
Declare Function SearchPath Lib "kernel32" Alias "SearchPathA" _
(ByVal lpPath As String, ByVal lpFileName As String, _
ByVal lpExtension As String, ByVal nBufferLength As Long, _
ByVal lpBuffer As String, ByVal lpFilePart As String) As Long
Public Sub SearchDisk(ByVal Path As String, _
ByVal FileName As String, ByRef FilePath As String, _
ByRef JustFile As String)
Dim BuffSize As Long
Dim ReturnVal As Boolean
BuffSize = 255
FilePath = Space$(BuffSize)
JustFile = Space$(BuffSize)
ReturnVal = SearchPath(Path, FileName, ".ini" & Chr$(0), _
BuffSize, FilePath, JustFile)
End Sub
Public Sub Main()
Dim SearchFile As String, PathSearch As String, PathFile As String
Dim FileNameOnly As String
SearchFile = "Win"
PathSearch = "c:\my documents\"
SearchDisk PathSearch, SearchFile, PathFile, FileNameOnly
If FileNameOnly <> "" Then
Debug.Print Trim(PathFile)
Else
Debug.Print "Not Found."
End If
PathSearch = ""
SearchDisk PathSearch, SearchFile, PathFile, FileNameOnly
If Trim(FileNameOnly) <> "" Then
Debug.Print Trim(PathFile)
Else
Debug.Print "Not Found."
End If
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?