Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Chronometer / timer 1

Status
Not open for further replies.

easycode

Programmer
Jan 28, 2005
195
US
Hello everyone

I hope anyone can help me with this one. I need to put a chronometer/timer in a form. When i put the timer it starts with 47166 which is the time in seconds since the midnight, but i just want it to start from 1, 2,....so on, because i would like to determine the time that a process last during execution, this time is variable depending on the number of records entered in the system. Thanks for your help.

 
Why not store Now() to a variable that can be subtract from Now() at the end of the process, using DateDiff?
 
Thanks Remou that's a good idea, but i would like to keep the timer visible so the user can track the time each process last so i rather make it visible all the time counting up starting from 1.

Thanks
 
What timer are you using? You can use the Timer Interval and Timer event to update a textbox with elapsed time.
 
I am using both, in the timer interval i put 500 which will update the form every half of a second and in the timer event i wrote the code to display the time.
here is the code. Take alook in the form_timer is the control mytimer which display the timer but it will displays as 47166 then 47167, 47168 and so on.

Thank for your response

Private Sub Form_Load()
Mytimer.Caption = Timer
lbl1.Caption = "Processing ... -"
End Sub

Private Sub Form_Timer()
Mytimer.Caption = Timer
lblnumber = lblnumber + 1
If lblnumber = 1 Then
lbl1.Caption = "Processing ... -"
End If
If lblnumber = 2 Then
lbl1.Caption = "Processing ... \"
End If
If lblnumber = 3 Then
lbl1.Caption = "Processing ... |"
End If
If lblnumber = 4 Then
lbl1.Caption = "Processing ... /"
End If
If lblnumber = 5 Then
lblnumber = 0
End If
End Sub
 
How about:

Code:
Dim gdteStartTime

Private Sub Form_Load()
gdteStartTime = Now
mytimer.Caption = DateDiff("s", gdteStartTime, Now())
lbl1.Caption = "Processing ... -"
End Sub

Private Sub Form_Timer()
mytimer.Caption = DateDiff("s", gdteStartTime, Now())
lblnumber = lblnumber + 1
If lblnumber = 1 Then
lbl1.Caption = "Processing ... -"
End If
If lblnumber = 2 Then
lbl1.Caption = "Processing ... \"
End If
If lblnumber = 3 Then
lbl1.Caption = "Processing ... |"
End If
If lblnumber = 4 Then
lbl1.Caption = "Processing ... /"
End If
If lblnumber = 5 Then
lblnumber = 0
End If
End Sub
 
Thanks Remou, you actually gave me an idea, since the your suggestions gives me time in seconds from 1,2......, then i have created 2 more labels labelmin and labelhour and when the labelsec is > 60 then labelmin increments in 1 and the same thing for the hour and works just fine.

Thanks for your help
Enjoy the star
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top