We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,849 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Reset the counter

Hello everyone
In my app i'm using the counter and timer, But im stuck with resetting the counter
My code is:

If Timer2.Enabled = True Then
            counter = counter + 1   
            Label1.Text = counter    
            If Label1.Text = "180" Then
                Timer2.Enabled = false
                    Timer3.Enabled  = true 
                End If
            End If
            End Sub

 If Timer3.Enabled =  true then
            counter = counter + 1
            Label2.Text = counter 
            If Label1.Text = "80" Then
            Timer3.Enabled = False
            end if

But the problem is: When the second counter starts, It does continue on the first counter after it's stops which is 180, But what i was aiming for is to second counter to start from 0
Any idea?
Thanks

2
Contributors
4
Replies
4 Days
Discussion Span
6 Months Ago
Last Updated
6
Views
Question
Answered
Matigo
Light Poster
41 posts since Jul 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

I have no way of knowing where your code is being executed. Is any of the code inside the timer Tick event handlers? For what you are trying to do I would put the following code in the Timer2_Tick handler

counter += 1
Label1.Text = counter

If counter = 180 Then
    counter = 0
    Timer2.Enabled = false
    Timer3.Enabled = true
End If

then in Timer3_Click I would put

counter += 1
label2.Text = counter

If counter = 80 Then
    Timer3.Enabled = False
End If
Reverend Jim
Carpe per diem
Moderator
3,595 posts since Aug 2010
Reputation Points: 561
Solved Threads: 446
Skill Endorsements: 32

Thanks Jim, It really helped me
Sorry for the late reply as i been away thats why i didn't let you you know if it did work
Thanks as always

Matigo
Light Poster
41 posts since Jul 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Any time. I'll mark this as solved.

Reverend Jim
Carpe per diem
Moderator
3,595 posts since Aug 2010
Reputation Points: 561
Solved Threads: 446
Skill Endorsements: 32
Question Answered as of 6 Months Ago by Reverend Jim

Thanks

Matigo
Light Poster
41 posts since Jul 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0702 seconds using 2.67MB