Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42220

Need help starting timer and counter if checkbox is checked ?

$
0
0
Hello Guys

I need help with something probably quite basic on vb.net

I have form1 with 6 check boxes and form 2 with 6 timers and counters
So what i need is when i check the boxes on form 1 they'll start on load form 2 counting up

ie: if i check box1, 2 and 3 in form 1 when i press start in form 2 when it loads to start counting up the timer and counter 1,2 and 3

Now when i press start in form 1 loads form 2 and all 6 timers and counters starts counting up but not from 0 ?
I need them to start counting from 0 but if i check the boxes only ?

Will be very grateful if anyone can help, this is the code i have right now:



Public Class Form2
Dim counter As Integer

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
Timer1.Interval = 1000
counter = 0
Timer2.Enabled = True
Timer2.Interval = 1000
counter = 0
Timer3.Enabled = True
Timer3.Interval = 1000
counter = 0
Timer4.Enabled = True
Timer4.Interval = 1000
counter = 0
Timer5.Enabled = True
Timer5.Interval = 1000
counter = 0
Timer6.Enabled = True
Timer6.Interval = 1000
counter = 0

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
counter = counter + 1
Label1.Text = counter
End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
counter = counter + 1
Label2.Text = counter
End Sub

Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
counter = counter + 1
Label3.Text = counter
End Sub

Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
counter = counter + 1
Label4.Text = counter
End Sub

Private Sub Timer5_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer5.Tick
counter = counter + 1
Label5.Text = counter
End Sub

Private Sub Timer6_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer6.Tick
counter = counter + 1
Label6.Text = counter
End Sub
End Class


Many Thanks !

Viewing all articles
Browse latest Browse all 42220

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>