?
Solved

Time running program

Posted on 2003-03-15
5
Medium Priority
?
145 Views
Last Modified: 2010-05-01
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
0
Comment
Question by:Canon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 

Expert Comment

by:junkeira
ID: 8145124
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
 

Author Comment

by:Canon
ID: 8145403
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
 
LVL 1

Accepted Solution

by:
TrueIdiot earned 400 total points
ID: 8146090
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
 

Author Comment

by:Canon
ID: 8146546
Hello TrueIdiot ,

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

Canon
0
 
LVL 1

Expert Comment

by:TrueIdiot
ID: 8148892
Anytime man. Thanks for the points :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month14 days, 18 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question