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
uj5u.com熱心網友回復:
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Const iSeparator As Long = 50 '每200毫秒檢查一次用戶是否下令中斷;
Private Sub CommandButton1_Click()
callSleep
End Sub
Private 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
不好意思,時間關系,沒能測驗一下。。。
uj5u.com熱心網友回復:
您好,感謝,callSleep可以帶引數么?我需要停止一個指定的時間,再繼續執行下面的陳述句
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/126312.html
標籤:VB基礎類
