Contents

# Timer Function

此函式將傳回指定了從午夜零時算起、已逝去的秒數的值。

您必須先宣告一個變數以呼叫 Timer 函式，並將其指定為「長型」資料類型，否則傳回日期型值。

### Syntax:

      Timer

### Return value:

日期

### Example:

      Sub ExampleTimer
          Dim lSec As Long,lMin As Long,lHour As Long
          lSec = Timer
          MsgBox lSec, 0, "Seconds since midnight"
          lMin = Int(lSec / 60)
          lSec = lSec Mod 60
          lHour = Int(lMin / 60)
          lMin = lMin Mod 60
        MsgBox Format(lHour,"00") & ":"& Format(lMin,"00") & ":" & Format(lSec,"00"),  0, "The time is"
    End Sub

The Timer function measures time in seconds. To measure time in milliseconds use the Timer service available in the ScriptForge library.

相關主題

ScriptForge.Timer service