Function Delay(ByVal n As Single)
Dim tm1, tm2 As Single
tm1 = Timer
Do
tm2 = Timer
If tm2 < tm1 Then tm2 = tm2 + 86400
If tm2 - tm1 > n Then Exit Do
DoEvents
Loop
用这个,不需要控件,也不需要API,但是只有整数秒的精度
Public Function pause(seconds As Integer)
Const SECS_INDAY = 24! * 60 * 60
Dim start As Single
start = Timer
Do: Loop Until (Timer + SECS_INDAY - start) Mod SECS_INDAY >= seconds
End Function
Option Explicit
Public Declare Function GetTickCount Lib "kernel32" () As Long
Const MS_DELAY = 50 '20FPS
Public Function Delay(Times As Single)
Dim mblnRunning As Boolean
Dim mlngTimer As Long
Dim caculate As Single
mblnRunning = True
caculate = 0
Debug.Print Times
Do While mblnRunning And caculate < Times
If mlngTimer + MS_DELAY <= GetTickCount() Then
mlngTimer = GetTickCount()
caculate = caculate + 0.05
End If
DoEvents 'Important!
Loop
End Function