O'Reilly logo

VBScript in a Nutshell, 2nd Edition by Ron Petrusha, Matt Childs, Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Timer Function

Syntax

Timer(  )

Return Value

A Single.

Description

Returns the number of seconds since midnight.

Programming Tips and 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
    Dim i, j
    
    sStartTime = Timer()
    For i = 1 To 100
       Response.Write  "Hello <BR>"
       For j = 0 To 1000
       Next
    Next
    Response.Write "Time Taken = " & _
        FormatDateTime(Timer - sStartTime, vbShortTime) & _
          " Seconds"
    %>

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required