Hello,

I am writing a simple program. I want to select the date and time, it should appear like this: DAYS HOURS MINUTES SECONDS
when the time reached set date my timer must stop like this 0(d) 0(h) 0(m) 0(s) and show Form2. But my timer continues to count from 0 to negative. i dont know how can i stop the timer. Maybe this is something easy i just cant remember the syntax how to do it.. please help :)

Thanks in advance

Public Class Form1
Dim CurrentTime
Dim TargetTime

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Timer1.Enabled = False
Timer1.Stop()

End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
CurrentTime = NowDim RemTime = TargetTime - CurrentTime
txtDays.Text = RemTime.days
txtHours.Text = RemTime.hours
txtMinutes.Text = RemTime.minutes
txtSeconds.Text = RemTime.seconds

End Sub

Private Sub btnOn_Click(sender As Object, e As EventArgs) Handles btnOn.Click
TargetTime = txtDateTime.Value
Timer1.Enabled = True
Timer1.Start()
txtDateTime.Visible = False
btnOn.Visible = False
End Sub

End Class

Recommended Answers

All 3 Replies

I see you know about Timer1.Stop so why not in your Timer1 handler test for the value to be zero or less then stop the timer and call up your new form?

Hi rproffitt,

can you provide an example pls.

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.