Timer Property

   
Timer Property

Class

Microsoft.VisualBasic.DateAndTime

Syntax

 Timer 

Return Value

Double representing the number of seconds that have elapsed since midnight

Description

Returns the number of seconds since midnight

Programming Tips and Gotchas

  • Timer is classified as a function in VB 6 and as a read-only property in VB.NET.

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

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

     Dim sStartTime As Single Dim i As Integer      sStartTime = Timer(  )     For i = 1 To 100         Console.WriteLine("Hello")     Next i MsgBox("Time Taken = " & Timer(  ) - sStartTime & " Seconds") 

VB.NET/VB 6 Differences

While the Timer property returns a Double in VB.NET, the VB 6 Timer function returns a Single.

See Also

GetTimer Function

   


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