请给下面程序中的 FindFile = FindFile + FindFile(tFld.Path, sFile)这一句加上说明,谢谢。
OptionExplicitDimfsoAsNewFileSystemObjectDimfldAsFolderPrivateSubCommand1_Click()Me.M...
Option Explicit
Dim fso As New FileSystemObject
Dim fld As Folder
Private Sub Command1_Click()
Me.MousePointer = vbHourglass
Command1.Enabled = False
Text1.Enabled = False
Text2 = ""
FindFile Dir1.Path, Text1
Text2 = Text2 & vbCrLf & "Search complete"
Text2.SelStart = Len(Text2)
Command1.Enabled = True
Text1.Enabled = True
Me.MousePointer = vbDefault
End Sub
Private Function FindFile(ByVal sFol As String, sFile As String) As Long
Dim tFld As Folder, tFil As File, FileName As String
Set fld = fso.GetFolder(sFol)
For Each tFil In fld.Files
If Mid(tFil.Name, InStrRev(tFil.Name, ".") + 1) = Text1 Then _
Text2 = Text2 & fso.BuildPath(fld.Path, tFil.Name) & vbCrLf
Text2.SelStart = Len(Text2)
DoEvents
Next
If fld.SubFolders.Count > 0 Then
For Each tFld In fld.SubFolders
DoEvents
FindFile = FindFile + FindFile(tFld.Path, sFile)
Next
End If
End Function
Private Sub Drive1_Change()
Dim sDir As String
sDir = Drive1.Drive
If InStr(sDir, "\\") <> 0 Then
sDir = Trim(Mid(sDir, InStr(sDir, "\\")))
If InStr(sDir, "]") <> 0 Then sDir = Left(sDir, InStr(sDir, "]") - 1)
ElseIf InStr(sDir, "[") <> 0 Then
sDir = Trim(Left(sDir, InStr(sDir, "[") - 1))
End If
If Right(sDir, 1) <> "\" Then sDir = sDir & "\"
Dir1.Path = sDir
End Sub
Private Sub Form_Load()
Drive1_Change
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub 展开
Dim fso As New FileSystemObject
Dim fld As Folder
Private Sub Command1_Click()
Me.MousePointer = vbHourglass
Command1.Enabled = False
Text1.Enabled = False
Text2 = ""
FindFile Dir1.Path, Text1
Text2 = Text2 & vbCrLf & "Search complete"
Text2.SelStart = Len(Text2)
Command1.Enabled = True
Text1.Enabled = True
Me.MousePointer = vbDefault
End Sub
Private Function FindFile(ByVal sFol As String, sFile As String) As Long
Dim tFld As Folder, tFil As File, FileName As String
Set fld = fso.GetFolder(sFol)
For Each tFil In fld.Files
If Mid(tFil.Name, InStrRev(tFil.Name, ".") + 1) = Text1 Then _
Text2 = Text2 & fso.BuildPath(fld.Path, tFil.Name) & vbCrLf
Text2.SelStart = Len(Text2)
DoEvents
Next
If fld.SubFolders.Count > 0 Then
For Each tFld In fld.SubFolders
DoEvents
FindFile = FindFile + FindFile(tFld.Path, sFile)
Next
End If
End Function
Private Sub Drive1_Change()
Dim sDir As String
sDir = Drive1.Drive
If InStr(sDir, "\\") <> 0 Then
sDir = Trim(Mid(sDir, InStr(sDir, "\\")))
If InStr(sDir, "]") <> 0 Then sDir = Left(sDir, InStr(sDir, "]") - 1)
ElseIf InStr(sDir, "[") <> 0 Then
sDir = Trim(Left(sDir, InStr(sDir, "[") - 1))
End If
If Right(sDir, 1) <> "\" Then sDir = sDir & "\"
Dir1.Path = sDir
End Sub
Private Sub Form_Load()
Drive1_Change
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询