Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Do While Loop using time as the counter
I have a datalogger that I created a few years ago. I have been asked to
create a modified logger that will log the data (when the criteria is true) every 1 second for 10 seconds. In which case the counter will reset. How can I code the Do WHile loop to syncronize to seconds? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Do While Loop using time as the counter
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 "asmenut" wrote: I have a datalogger that I created a few years ago. I have been asked to create a modified logger that will log the data (when the criteria is true) every 1 second for 10 seconds. In which case the counter will reset. How can I code the Do WHile loop to syncronize to seconds? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Do While Loop using time as the counter
Thanks Tom
"Tom Ogilvy" wrote: 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 "asmenut" wrote: I have a datalogger that I created a few years ago. I have been asked to create a modified logger that will log the data (when the criteria is true) every 1 second for 10 seconds. In which case the counter will reset. How can I code the Do WHile loop to syncronize to seconds? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
For Next loop faster with counter after Next? | Excel Programming | |||
Counter variable in For Loop | Excel Programming | |||
Should I use Do-While loop for my record counter? | Excel Programming | |||
Counter & Loop tutorial website | Excel Programming | |||
On Screen Loop Counter | Excel Programming |