Hi all o7. How is the correct way to update a date variable?
Following code does a cycle every seconds (lots of things happen here which are commented for now) in 24th hour of the day, yesterday ≠ today will happen and calibration/registration check [at its simplest way] will take place. After checking and analyzing things (which is not the case) yesterday variable should become today to avoiding it to happen next seconds for that day. But it is not happening. The debug msgbox (it's not necessary for final app) will always indicate "01/01/0001" obviously "yesterday" will not follow the term "Today".
Additional question: "Today" is present in Date.Today, DateAndTime.Today and DateAndTime.Today with different accent colors. What are their differences?Code:Public Class FORMTEST Dim YESTERDAY As String Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick 'COMMENTED CODE If YESTERDAY IsNot Today.ToShortDateString Then MsgBox(YESTERDAY & vbNewLine & Today.ToShortDateString) 'THINGS ALSO HAPPEN HERE IN THE FUTURE YESTERDAY = Today.ToShortDateString End If End Sub End Class
What I've tried:
- Me.Invoke(Sub() / End Sub) Not sure why I did that but thought this is the matter of graphics update (codes in prior)
- Commenting all prior codes = same result.
- Tried both String type and date actual format = same result. Code is in string type I assume string is always simpler.
- Tried YESTERDAY = New Date(Today).ToShortDateString seems the dictation is faulty.




Reply With Quote
