?
Solved

Count down clock

Posted on 2015-01-26
6
Medium Priority
?
87 Views
Last Modified: 2015-01-26
I need to create a countdown clock that counts down from a starting value of 60 minutes and shows the progress of the countdown in a label field.  

As an example it would start with the label showing 1:00:00 and the count down every second form there showing the progress along the way.  

I would appreciate any help anybody could provide me.

Thanks
0
Comment
Question by:Mike_Stevens
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40570544
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40570603
Can I ask you why you need it? Because if you want a count down on a screen, it already exist! Check the "break" feature of https://technet.microsoft.com/en-us/sysinternals/bb897434
0
 
LVL 14

Expert Comment

by:frankhelk
ID: 40570618
Since that looks like some kind of programming homework, I'll try to point you the rough way I would ímplement it.

Create the project, i.e. a windows forms application
On the main window, place a label and a start button
Drop a timer object on the main window
Set the button properties (i.e. text)
Implement the onClick method for the button, write code for a counting variable which is set to a start value of timespan ( = 60 ) and add code for activation of of the timer object.
click the timer object below to view its properties and det them accordingly (i.e. the interval)
Doubleclick the timer object below the main window to create the onTick service method and fill it with the needed code (decrease value of the counter variable, display remaining value in the correct format, stop at the end, etc.)

Compile & test. Debug. Repeat as needed.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 40570648
Here's a quick example:
Public Class Form1

    Private TargetDateTime As DateTime
    Private WithEvents Tmr As New Timer

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Tmr.Interval = 1000
        Tmr.Enabled = False
        Label1.Text = "1:00:00"
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Button1.Enabled = False
        TargetDateTime = DateTime.Now.AddHours(1)
        Tmr.Start()
    End Sub

    Private Sub Tmr_Tick(sender As Object, e As EventArgs) Handles Tmr.Tick
        UpdateCountDown()
    End Sub

    Private Sub UpdateCountDown()
        Dim TS As TimeSpan = TargetDateTime.Subtract(DateTime.Now)
        If TS.TotalMilliseconds > 0 Then
            Label1.Text = TS.ToString("hh\:mm\:ss")
        Else
            Tmr.Stop()
            Label1.Text = "00:00:00"
            MessageBox.Show("Time's Up!")
            Button1.Enabled = True
        End If
    End Sub

End Class

Open in new window

0
 

Author Comment

by:Mike_Stevens
ID: 40570886
Frankhelk I can assure its not a homework assignment.
0
 

Author Comment

by:Mike_Stevens
ID: 40570901
Thanks Mike....exactly what I was looking for
0

Featured Post

How to Create Failover DNS Record Sets in Route 53

Route 53 has the ability to easily configure DNS record sets specifically for failover scenarios. These failover record sets can be configured to failover to full-blown deployments in other regions or to a static HTML page that informs your customers of the issue.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question