Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TIMER FUNCTION?? 1

Status
Not open for further replies.

Kryzsoccer

Programmer
Oct 15, 2002
85
US
Does anyone know of a way to get a timer function like the one in VB6. I want my program to perform an action every 10 minutes and I cannot figure out how to do it without the user performing an action. Any help would be appreciated thanks!!
 
A simple timer:

Sub Timer()
Application.Wait Now + TimeValue("00:00:10")
MsgBox ("10 sec has elasped")
End Sub

Maybe you can build on this.

Much Luck
 
This looks like exactly what I need but there is a problem. I am using Microsoft Word's VBA. It does not support application.wait. Do you know of any other way to do this. THANKS A LOT!
 
Ok, I'll bite. What can you do in Word every 10 minutes that you can't do in Excel?

BTW, if you really need Word, you can control it as an imbedded app from within Excel.
 
The problem is I do not have excel on my computer. Thanks for all the quick responses.
 
This is lifted straight out of the Help file under "Timer Function Example":


Timer Function Example

This example uses the Timer function to pause the application. The example also uses DoEvents to yield to other processes during the pause.

Code:
Dim PauseTime, Start, Finish, TotalTime
If (MsgBox("Press Yes to pause for 5 seconds", 4)) = vbYes Then
    PauseTime = 5    ' Set duration.
    Start = Timer    ' Set start time.
    Do While Timer < Start + PauseTime
        DoEvents    ' Yield to other processes.
    Loop
    Finish = Timer    ' Set end time.
    TotalTime = Finish - Start    ' Calculate total time.
    MsgBox &quot;Paused for &quot; & TotalTime & &quot; seconds&quot;
Else
    End
End If
 
Thanks a lot for the code. I completly forgot about the examples in the help file.
THANKS A LOT EVERYONE!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top