Results 1 to 3 of 3

Thread: Q: Displaying Uptime Program Is Running In A Label

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2000
    Posts
    27
    I've got a question.

    I'm making a program, but I want the time the program is running (NOT windows) to be displayed in a label, and I just can't figure out how to do this.. arghl.

    Does NE1 have an idea? Thnx
    Life's hard, but the front of a train is harder

  2. #2
    Addicted Member jcouture100's Avatar
    Join Date
    Aug 1999
    Posts
    141
    This is real quick and is not optimized in any way, but this will do the trick. Put a timer control (tmrTimeCheck) on your form and an elapsed time label (lblElapsedTime) on your form.

    Code:
    Option Explicit
    Public startTime As Variant
    Public curTime As Variant
    Public runTime As Variant
    
    Private Sub Form_Load()
        'Set Timer Interval and Enable it.
        tmrTimeCheck.Interval = 1000
        tmrTimeCheck.Enabled = True
        'Get the current time and time program started
        curTime = Now
        startTime = curTime
    End Sub
    
    Private Sub tmrTimeCheck_Timer()
        'update current time variable
        curTime = Now
        'calculate amount of time your app has been running
        runTime = curTime - startTime
        'display elapsed time in a label.
        lblElapsedTime.Caption = Format(runTime, "hh:mm:ss")
    End Sub
    JC

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2000
    Posts
    27
    Yes! Thank you it worked

    -----------------------------
    E-Mail: [email protected]
    ICQ UIN#: 31619676
    Life's hard, but the front of a train is harder

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width