[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 347
  • Last Modified:

Timer

How about the timer interval limits?
Need call to the Timer control after 10 minutes.

Thanks for help!
0
DaveHa
Asked:
DaveHa
  • 2
  • 2
  • 2
  • +1
1 Solution
 
psmith789Commented:
Milliseconds
ten minutes = 1000 x 60 x 10 = 600,000

BUT the maximum allowable value is 65,535 - so you need to set the interval to 60000 (one minute) and use a global or module variable to 'count to 10' before you activate whatever it is you are doing.

Don't forget to initialize and reset the variable!
0
 
Éric MoreauSenior .Net ConsultantCommented:
Try this instead:

Private Sub Timer1_Timer()
Static dtmInitialTime As Date

    If dtmInitialTime = 0 Then
        dtmInitialTime = Now
    ElseIf DateAdd("n", 10, dtmInitialTime) Then
        MsgBox "10 minutes had elapsed!!!"
        dtmInitialTime = Now
    End If
End Sub
0
 
psmith789Commented:
I'm not sure that syntax works - how about:  

Private Sub Timer1_Timer()
Static dtmInitialTime As Date

    If dtmInitialTime = 0 Then
        dtmInitialTime = Now
    ElseIf DateDiff(dtmInitialTime, Now, "n") > 10 Then
        MsgBox "10 minutes elapsed!!!"
        dtmInitialTime = Now
    End If
End Sub

- You can set the Interval property to 1000 to check this every second, or higher for less frequent checks.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
JuiletteCommented:
ElseIf DateDiff(dtmInitialTime, Now, "n") > 10 Then

Error on type....
       
0
 
mark2150Commented:
Set Timer1.Interval = 60000 - one minute

Private Sub Timer1_Timer()
Static Tics as Integer
const factor as integer = 10
Tics = (tics + 1) mod Factor
if tics < 0 then  ... do your 10 minute thing here ...
'
End Sub
0
 
mark2150Commented:
OOps! should be

If tics < 1 then ...

Sorry.

I just don't know WHY this type of error happens. I have an error correcting modem...

M
0
 
Éric MoreauSenior .Net ConsultantCommented:
Oups, sorry. A few characters left in somewhere between my head and my fingers!

As other experts had remarked, the correct syntax should be:
Private Sub Timer1_Timer()
Static dtmInitialTime As Date

    If dtmInitialTime = 0 Then
        dtmInitialTime = Now
    ElseIf DateAdd("n", 10, dtmInitialTime) < Now Then
        MsgBox "10 minutes had elapsed!!!"
        dtmInitialTime = Now
    End If
End Sub
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now