PDA

Click to See Complete Forum and Search --> : This app has been running for (time) =HOW TO DO?!!=


czaries
Jan 11th, 2000, 10:06 AM
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

JeffSM
Jan 11th, 2000, 10:39 AM
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

MartinLiss
Jan 11th, 2000, 11:48 AM
Put a timer on the form and set it's interval to 100. Then do the following: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

MartinLiss
Jan 12th, 2000, 01:45 AM
I forgot to include the HoursAndMinutes routine. Here it is.

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

czaries
Jan 12th, 2000, 11:16 AM
Thank you guys, and I did mean display it on a form.

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

czaries
Jan 12th, 2000, 11:24 AM
Thank You for the correction. I was wondering why it kept giving me an error...

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