Public duan As Boolean '断点Public Function Sleep2(T As Long)
Dim Savetime As Long
Dim ttttt As Boolean
Savetime = timeGetTime '记下开始时的时间
Do While timeGetTime < Savetime + T '循环等待
ttttt = duan
If ttttt = False Then Exit Function
If ttttt = False Then Label6.Caption = "已退sleep2"
DoEvents '转让控制权
Loop
End Function
Dim Savetime As Long
Dim ttttt As Boolean
Savetime = timeGetTime '记下开始时的时间
Do While timeGetTime < Savetime + T '循环等待
ttttt = duan
If ttttt = False Then Exit Function
If ttttt = False Then Label6.Caption = "已退sleep2"
DoEvents '转让控制权
Loop
End Function
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)Private Const iSeparator As Long = 50 '每200毫秒检查一次用户是否下令中断;
Private Sub CommandButton1_Click()
callSleep
End SubPrivate Sub callSleep()
Dim beginTime As Long
Dim theTime As Long
beginTime = GetTickCount()
Do While True
theTime = GetTickCount()
If beginTime + iSeparator < theTime Then
If CheckBox1.Value = True Then
Exit Sub
End If
beginTime = theTime
Label1.Caption = Str(theTime)
Sleep iSeparator
End If
DoEvents
Loop
End Sub
不好意思,时间关系,没能测试一下
callSleep可以带参数么?我需要停止一个指定的时间,再继续执行下面的语句