Countdown Timer in VB.NET

Izzysabir

New member
Joined
Jun 6, 2005
Messages
3
Programming Experience
Beginner
Does anyone know how to set up a countdown timer in VB net?? i need it to expire in 360 days. A colleague of mine is retiring and would like it on his desktop as a countdown to the bigday. :eek:)
 
Last edited by a moderator:
Hi,

First off, welcome to the forum. I hope you'll have nice time here at the vbdornetforums :)

Well, i attached an example/demo below so you can take a look at ...
btw, replace current values with commented ones ... you'll find sense i'm sure.

Happy coding ;)
 

Attachments

  • Countdown.zip
    22.5 KB · Views: 257
Here's for the people that don't want to download a zip file, unzip it, then start VS just to get 17 lines of code:

You'll need a form with a Label named Label1 and a System.Windows.Forms.Timer named Timer1
VB.NET:
'just don't forget to replace comments with present values

    Private cdTime As Integer = 10 '360
    Private cdDay As Integer = 4 '86400

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        cdDay -= 1
        Label1.Text = cdTime & " days remaining"
        If cdDay <= 0 Then
            cdTime -= 1
            cdDay = 4 '86400
        End If
        If cdTime <= 0 Then
            Timer1.Dispose()
            Label1.Text = "360 days have been passed"
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Label1.Text = String.Empty
    End Sub
 
Back
Top