|
-
May 24th, 2012, 02:59 PM
#1
A timer in Hrs, Mins + Secs
This is what I have so far.
Code:
Private Sub Label1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Text = Label1.Text + 0.01
End Sub
Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
If Label1.Text = 60 Then Label2.Text = Label2.Text + 1 And Label1.Text = 0
End Sub
Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click
End Sub
Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
If Label2.Text = 60 Then Label3.Text = Label3.Text + 1 And Label2.Text = 0
End Sub
End Class
The first part (Label 1 + Timer 1) works fine and it counts seconds but I want it to count minutes and hours too. I am quite new to VB so excuse any obvious mistakes. Help is much appreciated 
-Skrill
-
May 24th, 2012, 03:25 PM
#2
Re: A timer in Hrs, Mins + Secs
Got it working.
Here's the code I replaced the above with.
Code:
Private Sec As Integer = 0, Min As Integer = 0, Hours As Integer = 0
Private Sub Timer1_Tick() Handles Timer1.Tick
Sec += 1
If Sec = 60 Then Min += 1 : Sec = 0
If Min = 60 Then Hours += 1 : Min = 0
Label1.Text = Hours.ToString() & ":" & Min.ToString() & ":" & Sec.ToString()
End Sub
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
|