How to Build an Electronic Countdown Timer

Written by jaime avelar
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Build an Electronic Countdown Timer
Create an electronic counter using VB.NET. (electronic clock image by Andrey Chmelyov from Fotolia.com)

Having the knowledge to build an electronic countdown timer using code in Windows can save you time. An electronic timer can be built by using Microsoft Visual Basic.NET (VB.NET) -- an object-oriented computer programming language. An electronic timer can be used in a Windows application to count down and execute other processes when the timer stops counting. In a few steps, you will create a countdown timer by using a Timer control and a Label to display the time.

Skill level:
Moderate

Other People Are Reading

Things you need

  • Microsoft Visual Basic Express

Show MoreHide

Instructions

  1. 1

    Start Microsoft Visual Basic Express, then click "New Project..." on the left pane of your screen. Select "Windows Forms Application." Click "OK."

  2. 2

    Double-click "Button" on the "Toolbox" pane to add a new button control. Double-click "Timer" to add a timer control. The timer will be used to count down.

  3. 3

    Double-click "Label" to add a label. The label will be used to display the time as it's decreasing. Double-click "Button1" to open the "Form1.vb" module.

  4. 4

    Type the following under "Button1_Click" to set the Timer interval to 1 second, start the timer, and start counting down from 15 minutes from now.

        Timer1.Interval = 1000
    
        Timer1.Start()
    
        cntDown = Date.Now.AddMinutes(15)
    
  5. 5

    Click the "Form1.vb [Design]" tab and doube-click the "Timer" control on the bottom of your screen.

  6. 6

    Type the following under "Timer1_Tick" to check if the countdown has completed. If it has not, then continue getting the difference between the current time and the "cntDown" variable. Display the difference through the Label control.

        If cntDown < Date.Now Then
    
            Me.Timer1.Stop()
    
            MessageBox.Show("Countdown has completed!")
    
        Else
    
            Dim time Rem As TimeSpan = Me.cntDown.Subtract(Date.Now)
    
            Me.Label1.Text = String.Format("{0}:{1:d2}:{2:d2}", _
    
                                           timeRem.Hours, _
    
                                           timeRem.Minutes, _
    
                                           timeRem.Seconds)
    
        End If
    
  7. 7

    Press "F5" to execute the program, then click "Button1" to start counting down.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.