Results 1 to 6 of 6

Thread: This app has been running for (time) =HOW TO DO?!!=

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Posts
    16

    Post

    How do I display a live clock, updated every second, that shows how long you have been running the current application? Come on guys, I know it's possible...

    ------------------
    Webmaster Czaries
    http://www1.50megs.com/css

  2. #2
    Registered User
    Join Date
    Apr 1999
    Location
    Brazil
    Posts
    144

    Post

    I don't understood very well, you want put this code in your form/mdi or in a clock out the app, like allways visible?

    Jefferson

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,175

    Post

    Put a timer on the form and set it's interval to 100. Then do the following:
    Code:
    Private Sub Timer1_Timer()
    
        Static m_dTotal As Double
        Static m_dStart As Double
        Static m_dCurrent As Double
        Dim x As Integer
        
        m_dStart = Timer   ' Set start time.
        
        Do
            m_dCurrent = Timer - m_dStart
            x = x + 1
            If x = 500 Then
                Text1.Text = "Working for " & HoursAndMinutes(m_dTotal + m_dCurrent)
                x = 0
            End If
            DoEvents    ' Yield to other processes.
        Loop
    
    End Sub
    ------------------
    Marty

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,175

    Post

    I forgot to include the HoursAndMinutes routine. Here it is.

    Code:
    Public Function HoursAndMinutes(dSeconds) As String
    
        HoursAndMinutes = Format(dSeconds \ 3600, "00") & ":" _
                        & Format(((dSeconds \ 60) Mod 60), "00") & ":" _
                        & Format(dSeconds Mod 60, "00")
        
    End Function

    ------------------
    Marty

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Posts
    16

    Post

    Thank you guys, and I did mean display it on a form.

    ------------------
    Webmaster Czaries
    http://www1.50megs.com/css

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Posts
    16

    Post

    Thank You for the correction. I was wondering why it kept giving me an error...

    ------------------
    Webmaster Czaries
    http://www1.50megs.com/css

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