Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default 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
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
For Next loop faster with counter after Next? RB Smissaert Excel Programming 22 August 28th 06 05:12 AM
Counter variable in For Loop [email protected] Excel Programming 3 June 8th 06 06:56 PM
Should I use Do-While loop for my record counter? excelnut1954 Excel Programming 0 March 24th 06 09:25 PM
Counter & Loop tutorial website Jill[_7_] Excel Programming 1 June 25th 04 02:12 AM
On Screen Loop Counter simoncohen Excel Programming 3 April 2nd 04 10:36 AM


All times are GMT +1. The time now is 03:57 PM.

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

About Us

"It's about Microsoft Excel"