View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Patrick Dave Patrick is offline
external usenet poster
 
Posts: 249
Default Visual Basic Timer

Try something like this.

Dim mytime As Date
Dim mydelay As Single
Dim myseconds As Integer
myseconds = 5
If myseconds 0 Then
mydelay = myseconds / 86400
Else
Exit Sub
End If
mytime = Now()
Do While Now() < mytime + mydelay
DoEvents
Loop

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"Jay" wrote:
|I need to run a certain code for 5 seconds. (i.e. a DC motor hooked @ a
| certain speed). I assumed I would be able to use a "do while" loop and the
| =now(time) function but cannot seem to get it to work. Any tips?
| Thanks!