Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '------------------------------------------------------------------------------------------
- ' Notice of My Copyright and Intellectual Property Rights
- '
- ' Any intellectual property contained within the program by Joseph L. Bolen remains the
- ' intellectual property of the Joseph L. Bolen. This means that no person may distribute,
- ' publish or provide such intellectual property to any other person or entity for any
- ' reason, commercial or otherwise, without the express written permission of Joseph L. Bolen.
- '
- ' Copyright © 2016. All rights reserved.
- ' All trademarks remain the property of their respective owners.
- '-------------------------------------------------------------------------------------------
- ' Program Name: Count Down Timer Demo
- '
- ' Author: Joseph L. Bolen
- ' Date Created: 22 JUN 2016
- '
- ' Description: This program demonstrates the Timer component and its Tick event.
- ' Also, the program shows the use of the TimeSpan class.
- '
- ' Documentation is at:
- ' App's screen image is at: http://imgur.com/kEAb7h9
- ' App's Visual Basic .NET code is at http://pastebin.com/g80jutPz
- '-------------------------------------------------------------------------------------------
- Public Class CountDownForm
- Private secondsRemaining As Integer
- Private Sub CountDownForm_Load(sender As Object, e As EventArgs) _
- Handles MyBase.Load
- MyTimer.Interval = 1000 ' 1000 milliseconds = 1 second
- End Sub
- Private Sub MyTimer_Tick(sender As Object, e As EventArgs) _
- Handles MyTimer.Tick
- If secondsRemaining > 0 Then
- Dim ts As New TimeSpan(0, 0, secondsRemaining)
- TimeRemainingLabel.Text = ts.ToString("hh\:mm\:ss")
- secondsRemaining -= 1
- Else
- MyTimer.Stop()
- Beep()
- TimeRemainingLabel.ForeColor = Color.Red
- TimeRemainingLabel.Text = "Times Up!"
- 'MessageBox.Show("Times Up!",
- ' Me.Text,
- ' MessageBoxButtons.OK,
- ' MessageBoxIcon.Information)
- End If
- End Sub
- Private Sub StartButton_Click(sender As Object, e As EventArgs) _
- Handles StartButton.Click
- secondsRemaining = Convert.ToInt32((HoursNumUpDwn.Value * 3600) + (MinutesNumUpDwn.Value * 60) + SecondsNumUpDwn.Value)
- StartButton.Enabled = False
- SetTimeGroupBox.Enabled = False
- MyTimer.Start()
- End Sub
- Private Sub ResetButton_Click(sender As Object, e As EventArgs) _
- Handles ResetButton.Click
- ResetForm()
- End Sub
- Private Sub ResetForm()
- MyTimer.Stop()
- StartButton.Enabled = True
- SetTimeGroupBox.Enabled = True
- TimeRemainingLabel.ForeColor = Control.DefaultForeColor
- TimeRemainingLabel.Text = String.Empty
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment