Name

Timer Function

Syntax

Timer( )

Return Value

A Variant of subtype Single.

Description

Returns the number of seconds since midnight.

Programming Tips & Gotchas

  • You can use the Timer function as an easy method of passing a seed number to the Randomize statement, as follows:

Randomize Timer
  • The Timer function is ideal for measuring the time taken to execute a procedure or program statement, as the following ASP snippet shows:

    Dim sStartTime As Single
    Dim i As Integer
        
    sStartTime = Timer
        For i = 1 To 100
            Response.Write "Hello" & "<P>"
        Next i
            Response.Write "Time Taken = " & Timer - sStartTime & " Seconds"

Get VBScript in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.