Solved

Count down clock

Posted on 2015-01-26
6
85 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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

749 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