countdown timer problem! help me !

.NET programming topics
Post Reply
aksl
Sergeant
Sergeant
Posts: 20
Joined: Wed Jan 29, 2014 9:34 pm
Location: Kurunegala,Srilanka

countdown timer problem! help me !

Post by aksl » Wed Mar 05, 2014 3:29 pm

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.

:( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :(
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: countdown timer problem! help me !

Post by Neo » Wed Mar 12, 2014 9:24 pm

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!
Post Reply

Return to “.NET Programming”