-
Jul 18th, 2012, 01:11 PM
#1
Thread Starter
Member
Check if today's date changes
Could anyone give me some input on how to check if today's date changes?
For example, in my program I have a label, which show's today's date, and when the time hits midnight, it's expected of the label to change to 19/07/2012.
I need this procedure to be a Sub, which would be re-ran in a timer every hour, to check, since the program might be ran for multiple days at once.
Thank you.
-
Jul 18th, 2012, 01:23 PM
#2
Re: Check if today's date changes
Set the timer interval to whatever internal you want, store the previous date and do a comparison of the .Day property of the previous date to the current date.
-
Jul 18th, 2012, 01:47 PM
#3
Thread Starter
Member
Re: Check if today's date changes
Something like this, and placing it in the timer control?
VB.NET Code:
Public Sub checkDate() Dim thisDate As Date = Date.Today Dim nextDate As Date = thisDate.AddDays(1) Dim result As Integer = Date.Compare(thisDate, nextDate) If result = 0 Then thisDate = nextDate ElseIf result > 0 Then thisDate = nextDate End If End Sub
-
Jul 18th, 2012, 01:52 PM
#4
Re: Check if today's date changes
why bother even checking? jsut have a time that fires off every couple of seconds, and display the current date... if it changes, it changes, if not, it just displays the same date until it does change....
-tg
-
Jul 18th, 2012, 02:00 PM
#5
Thread Starter
Member
Re: Check if today's date changes
Originally Posted by techgnome
why bother even checking? jsut have a time that fires off every couple of seconds, and display the current date... if it changes, it changes, if not, it just displays the same date until it does change....
-tg
It's mainly due to the fact, that If I change the start date on a different form, the program won't change the date on the main form until the timer ticks to the next day.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|