[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 393
  • Last Modified:

How do you get a count down timer in your windows form app?

I need a count down timer, please show me how to code the count down timer in my windows form app.  Thank you.  i would need this done in visual basic.  The idea is to get it to run the count down and when it hits zero, it executes a process by clicking a certain button.  Thanks!
2 Solutions
Here's some code that should work.  Let me know if you have any questions!
'Put in form
    Dim WithEvents myTimer As New Timer()
    Dim time As Integer = 5000 'Measured in miliseconds

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        myTimer.Interval = 1000
    End Sub

    Private Sub myTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles myTimer.Tick
        time -= myTimer.Interval
        If time <= 0 Then
            'call code that you want executed
        End If
    End Sub

Open in new window

Mike TomlinsonMiddle School Assistant TeacherCommented:
I thought we answered this for you pretty well a couple of days ago?...

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now