Timer 函数:
返回表示自午夜以来已过的秒数的 Single 。
语法:
Timer
备注:
在 Windows 中, Timer函数返回秒的小数部分。In Windows, the Timer function returns fractional portions of a second. 在 Macintosh 中,定时器分辨率为 1 秒。
示例:
此示例使用 Timer 函数来暂停应用程序。This example uses the Timer function to pause the application. 该示例还使用**DoEvents** 在暂停过程中向其他进程生成。
Dim PauseTime, Start, Finish, TotalTime
If (MsgBox("Press Yes to pause for 5 seconds", 4)) = vbYes Then
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
MsgBox "Paused for " & TotalTime & " seconds"
Else
End
End If