Page 1 of 1

countdown timer problem! help me !

Posted: Wed Mar 05, 2014 3:29 pm
by aksl
I wrote a code for a countdown timer. It works fine. When i select a date from datetimepicker1,it starts counting.But after closing & re starting my software, datetimepicker1 comes back to date of today(IT MEANS: It doesn't keep the date i choosed first). it causes to count to wrong date.

i want to lock the datetimepicker1 after choosing a date. How to get kept the date i choosed in datetimepicker1 when opening it another times?

this is the code i wrote,

Dim startdate As DateTime = DateTime.Parse(Date.Now)
Dim enddate As DateTime = DateTime.Parse(DateTimePicker1.Text)
Dim ts As TimeSpan = enddate.Subtract(startdate)
Label1.Text = CStr(ts.Days) & " Days Remaining "

If ts.Days = 0 Then
Timer1.Dispose()
Label2.Text = "Today is your Birthday !"
End If

i want to lock the datetimepicker1 after choosing a date. How to get kept the date i choosed in datetimepicker1 when opening it another times?

how to correct this my brothers. Please hep me.

:( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :(

Re: countdown timer problem! help me !

Posted: Wed Mar 12, 2014 9:24 pm
by Neo
On Form Unload (Exit) event, you need to save the value in DateTime Picker to either a file or system registry. When you open your program, in On Load event, you need to find this value and restore the DT Picker.

See this code.

Good luck!