How to create a countdown whit days, hours, minutes ect.

Fábián Soma
Fábián Soma used Ask the Experts™
on
Hi all,
I want to create a countdown like this:
If the vbnet app starts the countdown started whit the value is today date + 3day
How can i mak this happen?
thanks fopr any replay
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009

Commented:
What KIND of VB.Net application are you creating here?...Console, WinForms, WPF, WebForms, something else?...

What have you done so far?  What other kinds of time periods are you going to use?  How does the user enter them?  etc...
Top Expert 2016
Commented:
DesignForm1.vb
Imports System.Threading
Public Class Form1
    Dim RemainingTime As TimeSpan
    Dim remaining As Integer
    Dim StartDate As Date
    Dim EndDate As Date
    Dim activatedAlready = False

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        StartDate = Date.Now
        'EndDate = StartDate.AddMinutes(1)
        EndDate = StartDate.AddDays(3)
        Label12.Visible = False
        Timer1.Interval = "1000"
        Timer1.Start()

    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        RemainingTime = EndDate - Date.Now
        remaining = RemainingTime.TotalSeconds
        If remaining > 0 Then


            Label3.Text = RemainingTime.Days
            Label4.Text = RemainingTime.Hours
            Label5.Text = RemainingTime.Minutes
            Label8.Text = RemainingTime.Seconds
        Else
            Timer1.Stop()
            Label12.Visible = True
        End If

    End Sub
End Class

Open in new window

Solution
2017-11-12_5-14-11.mp4
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009

Commented:
No response from author.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial