Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

會傳回 Single,代表午夜之後經歷的秒數。

語法

Timer

註解

在 Microsoft Windows 中 ,Timer 函數會以小數部分來返回一秒。 在 Macintosh 上,計時器解析度為一秒。

查詢範例

運算式

結果

SELECT Timer () As secondsPast FROM ProductSales GROUP BY Timer () ;

根據系統時間,並顯示在 SecondsPast 欄中,會返回午夜之後經過的秒數。

VBA 範例

附註: 下列範例示範如何在 Visual Basic for Applications (VBA) 模組中使用此函數。 如需使用 VBA 的詳細資訊,請在 [搜尋] 旁的下拉式清單中選取 [開發人員參考],並在 [搜尋] 方塊中輸入一個或多個字詞。

此範例使用 Timer 函數來暫停應用程式。 此範例也會使用 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

選擇正確的日期函數

Need more help?

Expand your skills
Explore Training
Get new features first
Join Microsoft Office Insiders

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?

Thank you for your feedback!

×