Click to See Complete Forum and Search --> : timer Qustion


sahilkhan
May 22nd, 2001, 07:27 AM
I need to make an timer which should start from 0:0:0 and gave me value in same format ( i dont need any counter )

Cimperiali
May 22nd, 2001, 09:10 AM
you may be interested in time differences
ie:
dim lngStart as double
dim lngEnd as double
dim lngResult as double
lngStart= Now
'do yourstuff
lngEnd=Now
lngResult = lngStart-lngEnd
'and maybe use format function on lngResult (or on lngStart AND lngEnd )to see lngResult as you like


Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.

coolbiz
May 22nd, 2001, 09:39 AM
Timer that ticks every 1 second right? So after 5 1/2 mins, it should display 0:5:30? Anyway consider the following:

A project with 1 form (Form1) and 3 text editor controls (Text1, Text2, Text3), a timer (Timer1) and lastly a command button (Command1). Text1 represents SEC, Text2 represents MIN and Text3 represents HR. Set .Interval property to 1000 (so that it will trigger every 1 second) and the .Enabled property to FALSE.

private Sub Command1_Click()
If (Command1.Caption = "&Start Timer") then
Text1.Text = "0"
Text2.Text = "0"
Text3.Text = "0"
Timer1.Enabled = true
Command1.Caption = "&Stop Timer"
else
Timer1.Enabled = false
Command1.Caption = "&Start Timer"
End If
End Sub

private Sub Text1_Change()
If (CInt(Text1.Text) = 60) then
Text1.Text = "0"
Text2.Text = CInt(Text2.Text) + 1
End If
End Sub

private Sub Text2_Change()
If (CInt(Text2.Text) = 60) then
Text2.Text = "0"
Text3.Text = CInt(Text2.Text) + 1
End If
End Sub

private Sub Timer1_Timer()
Text1.Text = CInt(Text1.Text) + 1
End Sub




-Cool Bizs