09-16-2024, 12:16 PM
Code: (Select All)
CheckDate = Date$
CheckTime = Time$
If CheckDate <> Date$ Then ' Midnight rolled over
CheckDate = Date$
CheckTime = Time$
End If
I don't think the above is going to catch any Midnight roll over for you. Follow along with me and think of this little scenario:
CheckDate = Date$ '23:59.9998 time (HH:MM:SSSS)
CheckTime = Time$ '23:59.9998 time
If CheckDate <> Date$ Then ' 23:59.9999 time ==> OH NOS! TIME DOESN'T MATCH! GET NEW TIME!
CheckDate = Date$ ' 23:59.9999 time
CheckTime = Time$ ' 00:00.0000 time <-- Midnight just rolled over between those times!
End If[/code]
As you can see, you're not preventing the Date from falling behind. If it can fall behind after the first CheckDate = Date$ assignment, then why can't it fall behind at the second CheckDate = Date$ assignment?
Seems to me like the only way to do what you're wanting would be to verify the date again before the PRINT statement. Check the CheckDate$ vs Date$ there, and if it's not the same at that point, then redo the process with the new date...
(And yet, that can't catch 100% of all date change errors, as the date might change in the millisecond after that check, and while the PRINT is printing the date...)
Sometimes you just have to shrug and say, "Close enough is close enough."