Time a loop
By: Burt Abreu Date: 13/10/1998

You may use this short code to time a loop or an opearation without milliseconds resolution.

Dim BeginTime As Date
Dim FinishTime As Date
Dim ElapsedTime As Long

BeginTime =
Now 'get the beginning time

'Your loop code...

FinishTime = Now
'get the time after you exit the loop

ElapsedTime =
DateDiff("s", BeginTime, FinishTime)
'figure how many seconds between them

'Display like this or with debug
lblStart.Caption = BeginTime
lblFinish.Caption = FinishTime
lblElapsed.Caption = "Elapsed time in seconds " & ElapsedTime

The function DateDiff is used to calculate a difference between two dates. You specify the resolution of the difference (s = seconds), the first date and the second date. Remember that for Visual Basic a "date" contains the current day and time.
Now function gives the current instant (day and time).

Click Here!

Visual Basic Programming Zone is a website by Lorenzo Dalla Vecchia.
Webmaster's e-mail: webmaster@vbprogzone.cjb.net
Hosted by InWind: www.inwind.it