以下是我自己写的搜索函数,请问函数被调用之后怎么让它暂停下来又怎么让它继续执行?

Public Sub SearchSuffix(ByVal Path As String, ByVal Suffix As String)
On Error Resume Next
Dim PathChild() As String
Dim SPath As String
Dim Temp As Long
Dim Number As Long
Dim CurrentPath As String
If Right(Path, 1) <> "\" Then
Path = Path & "\"
End If
SPath = Dir(Path, vbNormal Or vbReadOnly Or vbHidden Or vbSystem Or vbDirectory Or vbVolume)
Do While SPath <> "" 
CurrentPath = Path & SPath
Form1.StaPath.Panels(1).Text = CurrentPath
DoEvents
If SPath <> "." And SPath <> ".." Then
' 使用位比较来确定 SPath 代表一目录。
If (GetAttr(Path & SPath) And vbDirectory) = vbDirectory Then
Temp = Temp + 1
ReDim Preserve PathChild(Temp)
PathChild(Temp) = SPath
Else
If UCase(Right(SPath, Len(Suffix))) = UCase(Suffix) Then
Form1.List1.AddItem Path & SPath
End If
End If
End If
SPath = Dir
Loop
For Number = LBound(PathChild) To UBound(PathChild)
If PathChild(Number) <> "" Then
SearchSuffix Path & PathChild(Number), Suffix
End If
Next Number

End Sub

Smart猫小萌
浏览 123回答 3
3回答

临摹微笑

API函数sleep()功能暂停执行,参数单位毫秒如:sleep(1000) 暂停1秒Public Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

神不在的星期二

dim needtostop as booleanPrivate Sub Form_Load()needtopause=falseend subprivate sub buttonpauseclick()needtopause=trueend subprivate sub buttonresumeclick()needtopause=falseend sub....Do While SPath <> ""&nbsp;CurrentPath = Path & SPathForm1.StaPath.Panels(1).Text = CurrentPathDoEventswhile needtopausedoeventswendIf SPath <> "." And SPath <> ".." Then' 使用位比较来确定 SPath 代表一目录。....这样应该在制定的loop之内暂停

大话西游666

While条件加一个(Not Pause),跳出While之后记录下CurrentPath
打开App,查看更多内容
随时随地看视频慕课网APP