Private Declare Function GetTickCount Lib "kernel32" () As Long
Sub main()
Dim t, ms As Long
Debug.Print
ms = 500 '单位是毫秒
Debug.Print Timer
'每次只启用一个call
Application.Calculate
Call delay(ms, 1, 2) '2楼
Call PauseHalfSec(ms, 4, 5) '3楼
Call aa(ms, 7, 8) '4楼
Call DelayEx(ms, 10, 11)
Debug.Print Timer
End Sub
Sub delay(ms As Long, x As Long, y As Long)
Dim t As Double
Dim dl As Double
dl = ms / 1000
Cells(x, 1) = Cells(1, 2).Value
t = Timer
Do While Timer - dl < t
Loop
Application.Calculate
Cells(y, 1) = Cells(1, 2).Value
End Sub
Sub PauseHalfSec(ms As Long, x As Long, y As Long)
Dim S As Double
Dim dl As Double
dl = ms / 1000
Cells(x, 1) = Cells(1, 2).Value
S = Timer
Do
Loop Until Timer - S >= dl
Application.Calculate
Cells(y, 1) = Cells(1, 2).Value
End Sub
Sub aa(ms As Long, x As Long, y As Long)
Dim dl As Double
dl = ms / 1000
Cells(x, 1) = Cells(1, 2).Value