Time running program

Hey All, Need some working code which will time a program and allow it to run for 20 minutes and then automatically end the program.

Thanks

Canon
CanonAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
TrueIdiotConnect With a Mentor Commented:
Do it this way:

Private Sub Timer1_Timer()
   static intMinutes as integer

   'set the timer length for 60000 (one minute)

   if intMinutes < 20
      intMinutes = intMinutes + 1
   else
      unload Form1 'or whatever exit code you use
   endif
End Sub
0
 
junkeiraCommented:
Create a form with a Timer and write this:

Dim initialtime
Private Sub Form_Load()
    initialtime = Timer
End Sub
Private Sub Timer1_Timer()
    'Set timer to 60000 = it tests every minute
    If Timer - initialtime >= 1200 Then End '1200 = 20 minutes
End Sub
0
 
CanonAuthor Commented:
Hey junkeira ;
   I used your code but it seems to stop the program in one minute instead of five ?

Any ideas?

Thank You

Canon
0
 
CanonAuthor Commented:
Hello TrueIdiot ,

   Thanks for the code, it was just what I needed and it worked the first time without any tweaking :)

Canon
0
 
TrueIdiotCommented:
Anytime man. Thanks for the points :)
0
All Courses

From novice to tech pro — start learning today.