Discussion:
Timers vb6
(too old to reply)
g***@gmail.com
2014-12-31 06:51:50 UTC
Permalink
Dear All,

How to make a timer Unload Me/App until 30 minute from loaded App/form.

Thanks in advance


Cheers
Andrew s
2014-12-31 11:40:52 UTC
Permalink
SOLVED. Thanks
Deanna Earley
2015-01-02 10:12:25 UTC
Permalink
Post by Andrew s
Post by g***@gmail.com
How to make a timer Unload Me/App until 30 minute from loaded App/form.
SOLVED. Thanks
For anyone else that finds this, the easiest solution is to have a timer
fire every 30s (or any value up to but less than 60s) which then used
DateDiff() to calculate the time since it started (using a single Date
variable with "Now" assigned to it) and calling Unload Me if it's
greater than 30 minutes.

Private Started As Date

Private Sub Form_Load()
'Record the current time
Started = Now
End Sub

Private Sub ShutdownTimer_Timer()
'Check if the minute component has increased by 30
If DateDiff("n", Started, Now) > 30 Then Unload Me
End Sub

Note that this could be off by up to 1 minute either way due to the
frequency of the timer and the check not taking into account seconds.
To get around that, you can reduce the timer interval, and check the
number of seconds since it started in the timer.
--
Deanna Earley (***@earlsoft.co.uk, ***@doesnotcompute.co.uk)

(Replies direct to my email address will be printed, shredded then fed
to the rats. Please reply to the group.)
Loading...