Results 1 to 5 of 5

Thread: Timer.Start() not starting timer.

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2015
    Posts
    2

    Question Timer.Start() not starting timer.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSpin.Click
    btnSpin.Enabled = False
    Dim rng As New Random
    SpinTime = rng.Next(8, 30)
    .
    .
    .
    Timer1.Start()
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
    PicBoxSpinner.Image = Wheel1
    lblTest.Text = 1
    If SpinCount > 0 Then
    Timer2.Start()
    SpinCount -= 1
    Else
    btnContinue.Enabled = True
    End If
    Timer1.Stop()
    End Sub

    I got rid of some stuff that's not important.

    When I execute the above lines of code, it runs through them after I press button1, and then, once reaching the end of the sub, just stops, without running the timer. Any suggestions?

  2. #2
    Frenzied Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    1,187

    Re: Timer.Start() not starting timer.

    Your timer sub is not handling the tick event of the timer...

  3. #3
    PowerPoster SJWhiteley's Avatar
    Join Date
    Feb 2009
    Location
    South of the Mason-Dixon Line
    Posts
    2,256

    Re: Timer.Start() not starting timer.

    You stop the timer - Timer1.Stop()

    Also, there isn't a 'handles' after Timer1_Tick() did you delete it when posting, or does it truly not exist?

    Additionally, I'd eliminate the second timer if I were you. It is rarely, if ever, necessary to have multiple timers (assuming Timer2 refers to a forms timer).
    "Ok, my response to that is pending a Google search" - Bucky Katt.
    "There are two types of people in the world: Those who can extrapolate from incomplete data sets." - Unk.
    "Before you can 'think outside the box' you need to understand where the box is."

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2015
    Posts
    2

    Re: Timer.Start() not starting timer.

    Hmm, thanks... Didn't notice the handler was missing. I can't recall deleting it but I guess I did somewhere along the line. An easy fix, thanks!

  5. #5
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,460

    Re: Timer.Start() not starting timer.

    Quote Originally Posted by KieranMoynihan View Post
    Hmm, thanks... Didn't notice the handler was missing. I can't recall deleting it but I guess I did somewhere along the line. An easy fix, thanks!
    Did you possibly cut and paste that Timer at some point? Less likely with a component than a control but if you cut and paste anything in the designer then all Handles clauses containing the corresponding field will be removed when you cut.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width