GetTimer Function

   
GetTimer Function

Class

Microsoft.VisualBasic.VBMath

Syntax

 GetTimer(  ) 

Return Value

A Double indicating the number of seconds

Description

Returns the number of seconds since midnight

Programming Tips and Gotchas

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

     Randomize GetTimer(  ) 
  • The GetTimer function is ideal for measuring the time taken to execute a procedure or block of code, as the following snippet shows:

     Dim dblStartTime As Double Dim i As Integer dblStartTime = Timer(  ) For I = 1 to 100    Console.WriteLine("Hello") Next Console.WriteLine("Time Taken = " & GetTimer(  ) - _                   dblStartTime & " Seconds") 

VB.NET/VB 6 Differences

  • The GetTimer function is new to VB.NET. However, it is functionally identical to the VB 6 Timer function (and VB.NET Timer property), which continues to be supported.

  • In contrast to the VB 6 Timer function, which returned a Single, the VB.NET GetTimer function and Timer property return a Double.

See Also

Timer Property

   


VB.Net Language in a Nutshell
VB.NET Language in a Nutshell
ISBN: B00006L54Q
EAN: N/A
Year: 2002
Pages: 503

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net