Private Sub waite(y) Dim startime As Date, endtime As Date Const seconds = "s" startime = Time endtime = Time Do While DateDiff(seconds, startime, endtime) < y endtime = Time() DoEvents Loop End Sub
试下这样,Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Private Declare Function GetTickCount Lib "kernel32" () As Long Private Declare Function GetInputState Lib "user32" () As LongPrivate Sub Delay(DelayTime As Long) Dim i As Long Dim EndTime As Long EndTime = GetTickCount + DelayTime Do Until GetTickCount > EndTime i = i + 1 If GetInputState Then DoEvents If i = 100000 Then Sleep 10 i = 0 End If Loop End Sub
doevents
即可
http://topic.csdn.net/t/20050805/17/4191555.html
Dim startime As Date, endtime As Date
Const seconds = "s"
startime = Time
endtime = Time
Do While DateDiff(seconds, startime, endtime) < y
endtime = Time()
DoEvents
Loop
End Sub
试下这样,Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Declare Function GetInputState Lib "user32" () As LongPrivate Sub Delay(DelayTime As Long)
Dim i As Long
Dim EndTime As Long
EndTime = GetTickCount + DelayTime
Do Until GetTickCount > EndTime
i = i + 1
If GetInputState Then DoEvents
If i = 100000 Then
Sleep 10
i = 0
End If
Loop
End Sub