为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

Smart猫小萌 2022-12-21 19:15:33
Public Sub SearchSuffix(ByVal Path As String, ByVal Suffix As String)On Error Resume NextDim PathChild() As StringDim SPath As StringDim Temp As LongDim Number As LongDim CurrentPath As StringIf Right(Path, 1) <> "\" ThenPath = Path & "\"End IfSPath = Dir(Path, vbNormal Or vbReadOnly Or vbHidden Or vbSystem Or vbDirectory Or vbVolume)Do While SPath <> "" CurrentPath = Path & SPathForm1.StaPath.Panels(1).Text = CurrentPathDoEventsIf SPath <> "." And SPath <> ".." Then' 使用位比较来确定 SPath 代表一目录。If (GetAttr(Path & SPath) And vbDirectory) = vbDirectory ThenTemp = Temp + 1ReDim Preserve PathChild(Temp)PathChild(Temp) = SPathElseIf UCase(Right(SPath, Len(Suffix))) = UCase(Suffix) ThenForm1.List1.AddItem Path & SPathEnd IfEnd IfEnd IfSPath = DirLoopFor Number = LBound(PathChild) To UBound(PathChild)If PathChild(Number) <> "" ThenSearchSuffix Path & PathChild(Number), SuffixEnd IfNext NumberEnd Sub
查看完整描述

3 回答

?
临摹微笑

TA贡献1982条经验 获得超2个赞

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


查看完整回答
反对 回复 2022-12-25
?
神不在的星期二

TA贡献1963条经验 获得超6个赞

dim needtostop as boolean
Private Sub Form_Load()
needtopause=false
end sub

private sub buttonpauseclick()
needtopause=true
end sub

private sub buttonresumeclick()
needtopause=false
end sub

....
Do While SPath <> "" 
CurrentPath = Path & SPath
Form1.StaPath.Panels(1).Text = CurrentPath
DoEvents
while needtopause
doevents
wend
If SPath <> "." And SPath <> ".." Then
' 使用位比较来确定 SPath 代表一目录。

....

这样应该在制定的loop之内暂停


查看完整回答
反对 回复 2022-12-25
?
大话西游666

TA贡献1817条经验 获得超14个赞

While条件加一个(Not Pause),跳出While之后记录下CurrentPath

查看完整回答
反对 回复 2022-12-25
  • 3 回答
  • 0 关注
  • 122 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号