|
-
Nov 15th, 2006, 05:40 AM
#1
Thread Starter
Lively Member
[RESOLVED] Triple Stopwatch
Hey,
Okay I'm trying to make this (using VB6.0):
- A form with three labels, and a Start button beneath each label. There's also one Stop and one Exit button.
- All the three labels are stopwatches showing 00:00:00 (hh:mm:ss).
- When a Start button is pushed the stopwatch is started on the label above.
- Also, pressing a Start button will stop all other stopwatches. (If they are on, that is)
I already searched these forums for a similar topic, found a few but got no help from them. So if you have any quidelines for this project, I'd approciate your help!
I'm quite new to VB and haven't coded anything in a while.
And no, I don't need a ready code, but a few hints here and there would be nice.
Thanks, Rade
PS Got to go now but will be back later today
"Real men don't use backups, they post their stuff on a public ftp server and let the rest of the world make copies."
- Linus Torvalds
-
Nov 15th, 2006, 05:50 AM
#2
Re: Triple Stopwatch
VB Code:
'Add One Label Called lblstopwatch
'add one timer
'add two commandbutton and name them as cmdstarttimer and cmdstoptimer
Dim Time2 As Date
Private Sub cmdstarttimer_Click()
Timer1.Enabled = True
End Sub
Private Sub cmdstoptimer_Click()
Timer1.Enabled = False
End Sub
Private Sub Form_Load()
Timer1.Interval = 1000 'timer time is 1 second
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
lblstopwatch.Caption = Format$(Time2, "hh") & ":" & Format$(Time2, "nn") & ":" & Format$(Time2, "ss")
Time2 = DateAdd("s", 1, Time2)
End Sub
Last edited by danasegarane; Nov 15th, 2006 at 05:55 AM.
Reason: Timer interval changed
Please mark you thread resolved using the Thread Tools as shown
-
Nov 15th, 2006, 07:59 AM
#3
Thread Starter
Lively Member
Re: Triple Stopwatch
danasegarane, Thank You! That was exactly what I needed Or yes I made modifications but anyways, thanks!
One thing still:
If I want to have a Reset button that would put the stopwatch back to 00:00:00, is there an easier way to do it than this:
VB Code:
Private Sub cmdReset_Click()
Time2 = "00:00:00"
lblstopwatch.Caption = "00:00:00"
End Sub
Because if I put it like this:
VB Code:
Private Sub cmdReset_Click()
Time2 = "00:00:00"
lblstopwatch.Caption = Time2
End Sub
...The label will show 0:00:00 instead of 00:00:00 for one second. Then it changes back.
Thank you again 
Cheers, Rade
"Real men don't use backups, they post their stuff on a public ftp server and let the rest of the world make copies."
- Linus Torvalds
-
Nov 15th, 2006, 09:04 AM
#4
Re: Triple Stopwatch
Dear Rade,
Here is the modifed version
VB Code:
'Add One Label Called lblstopwatch
'add one timer
'add two commandbutton and name them as cmdstarttimer and cmdstoptimer
Dim Time2 As Date
Private Sub cmdreset_Click()
Timer1.Enabled = False 'stop the timer
lblstopwatch.Caption = "00:00:00" 'reset the label
Time2 = Date 'reset the date varriable
End Sub
Private Sub cmdstarttimer_Click()
Timer1.Enabled = True 'start the timer
End Sub
Private Sub cmdstoptimer_Click()
Timer1.Enabled = False 'stop the timer
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
lblstopwatch.Caption = "00:00:00" 'reset the label
End Sub
Private Sub Timer1_Timer()
lblstopwatch.Caption = Format$(Time2, "hh") & ":" & Format$(Time2, "nn") & ":" & Format$(Time2, "ss")
Time2 = DateAdd("s", 1, Time2)
End Sub
Please mark you thread resolved using the Thread Tools as shown
-
Nov 15th, 2006, 09:20 AM
#5
Thread Starter
Lively Member
Re: Triple Stopwatch
Oh, thank you again I Really approciate this!
One last little tiny thing if you have time:
When I start the timer it lasts 2 seconds before is shows 00:00:01. Is there any way to fix this? It's not that important but... 
Rade
"Real men don't use backups, they post their stuff on a public ftp server and let the rest of the world make copies."
- Linus Torvalds
-
Nov 15th, 2006, 09:30 AM
#6
Re: Triple Stopwatch
replace this coding
in your From
VB Code:
Private Sub Timer1_Timer()
Time2 = DateAdd("s", 1, Time2)
lblstopwatch.Caption = Format$(Time2, "hh") & ":" & Format$(Time2, "nn") & ":" & Format$(Time2, "ss")
End Sub
Please mark you thread resolved using the Thread Tools as shown
-
Nov 15th, 2006, 10:26 AM
#7
Thread Starter
Lively Member
Re: Triple Stopwatch
Alright!
Thank You for the help 
Rade
"Real men don't use backups, they post their stuff on a public ftp server and let the rest of the world make copies."
- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|