Visual Basic Express

I am looking for a way to add a count down clock to a form using Visual Basic Express.  I want to give the user a 30 minute warning before shutting down their computer.  I would like to have a count down beginning at 30:00.
bosn1Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
One way:
Public Class Form1
 
    Private targetDT As DateTime
    Private WithEvents tmr As New Timer
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        targetDT = DateTime.Now.AddMinutes(30)
        tmr.Interval = 1000
        tmr.Start()
    End Sub
 
    Private Sub tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick
        Dim ts As TimeSpan = targetDT.Subtract(DateTime.Now)
        If ts.TotalMilliseconds <= 0 Then
            tmr.Stop()
 
            MessageBox.Show("Time's up!")
 
        Else
            Label1.Text = ts.Minutes & ":" & ts.Seconds.ToString.PadLeft(2, "0")
        End If
    End Sub
 
End Class

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bosn1Author Commented:
I was hoping to display a 30 minute count down, i.e.

30:00
29:59
29:58
0
bosn1Author Commented:
I must have missed something the first time.  The soultion provided by Idle Mind is exactly what I need.

Thank you
0
Daniel WilsonCommented:
Excellent!

I see you're relatively new to EE.  Welcome!

Since Idle_Mind's solution is what you needed, would you click the Accept link by his solution to close out the question and award him the points?

Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.