Solved

Count down clock

Posted on 2015-01-26
6
86 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 86

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

Stressed Out?

Watch some penguins on the livecam!

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

691 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