LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Tom Ogilvy - Timer help

Tom, you posted this brilliant piece of code (below) in a response to a
question with the title " Do while loop using time as the counter". I found
it (potentially) extremely useful and intricate. So much so that I don't know
how to adapt it to my own purpose, which is to initiate a validation
procedure on a sheet at user given intervals, for instance every two minutes.
Can you (or somebody equally gifted) explain how I modify the code to loop
every e.g. 120 seconds until the user specifically orders the procedure to
stop?

Your help would be greatly appreciated!

Henrik



Public Declare Function SetTimer Lib "user32" ( _
ByVal hwnd As Long, ByVal nidevent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Public Declare Function KillTimer Lib "user32" ( _
ByVal hwnd As Long, ByVal nidevent As Long) As Long

Public timerid As Long
Public timerseconds As Single
Public Cnt As Long

Sub StartTimer()
timerseconds = 1 'how often to "pop"the timer
Cnt = 0
timerid = SetTimer(0&, 0&, timerseconds * 1000&, _
AddressOf Timerproc)
End Sub

Sub endtimer()
On Error Resume Next
KillTimer 0&, timerid
End Sub

Sub Timerproc(ByVal hwnd As Long, ByVal umsg As Long, _
ByVal nidevent As Long, ByVal dwtimer As Long)
Range("A1").Value = Cnt + 1
Beep
Cnt = Cnt + 1
If Cnt < 10 Then Exit Sub

endtimer
End Sub

write your log in the timerproc
--
Regards,
Tom Ogilvy


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Who or What is Tom Ogilvy? Stella Excel Programming 23 July 22nd 06 07:33 PM
Tom Ogilvy or anyone else who can help! Jennifer Excel Programming 2 May 24th 06 03:37 AM
Stopping a Timer / Running a timer simultaneously on Excel Paul23 Excel Discussion (Misc queries) 1 March 10th 06 12:08 PM
Tom Ogilvy or anyone that can help Brian W. Excel Programming 7 September 25th 04 12:52 AM
Tom Ogilvy David Joseph Excel Programming 0 April 21st 04 02:57 PM


All times are GMT +1. The time now is 10:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"