Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
500MB 27GB Web Hosting - $9.95/Month
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleMeasure elapsed time
Keywordselapsed time, time, timer function, seconds
CategoriesSoftware Engineering, Tips and Tricks
 
Declare two Double variables for the start and stop times. Set their values using the Timer function, which returns the number of seconds that have passed since midnight (yes, that means this doesn't work if the time interval spans midnight). Subtract the values and use Format to display the result.
 
Private Sub cmdStart_Click()
Static start_time As Double
Dim stop_time As Double
Dim elapsed_time As Double

    If cmdStart.Caption = "Start" Then
        lblElapsed.Caption = ""
        start_time = Timer
        cmdStart.Caption = "Stop"
    Else
        stop_time = Timer
        elapsed_time = stop_time - start_time
        lblElapsed.Caption = Format$(elapsed_time, _
            "0.000000")
        cmdStart.Caption = "Start"
    End If
End Sub
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated