Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.basic.visual.misc > #2216 > unrolled thread

Timers vb6

Started bygeomodelers@gmail.com
First post2014-12-30 22:51 -0800
Last post2015-01-02 10:12 +0000
Articles 3 — 3 participants

Back to article view | Back to comp.lang.basic.visual.misc


Contents

  Timers vb6 geomodelers@gmail.com - 2014-12-30 22:51 -0800
    Re: Timers vb6 Andrew s <geomodelers@gmail.com> - 2014-12-31 03:40 -0800
      Re: Timers vb6 Deanna Earley <dee@earlsoft.co.uk> - 2015-01-02 10:12 +0000

#2216 — Timers vb6

Fromgeomodelers@gmail.com
Date2014-12-30 22:51 -0800
SubjectTimers vb6
Message-ID<4360cb1a-4f7e-451a-9645-59b11166d1e9@googlegroups.com>
Dear All,

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

Thanks in advance


Cheers

[toc] | [next] | [standalone]


#2217

FromAndrew s <geomodelers@gmail.com>
Date2014-12-31 03:40 -0800
Message-ID<78240854-a5c0-46a1-a270-781aa97a26ec@googlegroups.com>
In reply to#2216
SOLVED. Thanks

[toc] | [prev] | [next] | [standalone]


#2219

FromDeanna Earley <dee@earlsoft.co.uk>
Date2015-01-02 10:12 +0000
Message-ID<m85r1n$df7$1@speranza.aioe.org>
In reply to#2217
On 31/12/2014 11:40, Andrew s wrote:
> On 31/12/2014 06:51, geomodelers@gmail.com wrote:> Dear All,
>> 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 (dee@earlsoft.co.uk, dee@doesnotcompute.co.uk)

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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.basic.visual.misc


csiph-web