Solved

Count down clock

Posted on 2015-01-26
6
83 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
6 Comments
 
LVL 24

Expert Comment

by:Phillip Burton
Comment Utility
0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
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 13

Expert Comment

by:frankhelk
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
Comment Utility
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
Comment Utility
Frankhelk I can assure its not a homework assignment.
0
 

Author Comment

by:Mike_Stevens
Comment Utility
Thanks Mike....exactly what I was looking for
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Select datagridview rows by range or numbers 11 21
Code enhancement 5 12
String manipulation 15 48
Setting runtime form location 4 18
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now