creating a countdown

bradgate08

New member
Joined
Sep 14, 2008
Messages
4
Programming Experience
Beginner
hi im new to visual basic and im currently using visual basic.net 2003,

what i am trying to do is create a continuous countdown that will use the system time to calculate how long there is left in the countdown. i need it to display how many weeks, days, hours, minutes and seconds there are left; the date that i would like it to countdown to is the 28th october 2008.

if you can help i would appreciate it

thanx
 
Hello.

You can use Date.Substract to get the difference as a Timespan. I'd say that you use a timer which ticks every half second and calculates this.

Have a look at the TimeSpan object, it has Properties for Total Days/Hours etc.

Bobby
 
hi its me again i tried to understand the function you described to me but i just cant do it do you think you could provide the basis of the coding required?

thanx
 
VB.NET:
Sub countdown()
    Dim now As Date = Date.Now
    Dim target As New Date(now.Year, 12, 31)
    Dim remaining As TimeSpan = target.Subtract(now)
    Dim msg As String = String.Format("there are {0} days left this year.", remaining.Days)
    MsgBox(msg)
End Sub
 
thanx for your post i have used the code you supplied and adapted it to suit my needs but no i am stuck so i was wondering if you could tell me what i do next plz?

here is what i have dne so far:

Dim now As Date = Date.Now
Dim target As New Date(now.Year, 10, 28, 0, 0, 0)
Dim remaining As TimeSpan = target.Subtract(now)
Dim countdownrate As Date =
countdownrate = Countdown.Text



thanx
 
Back
Top