How to use Timer without using timer control
Posted on January 4, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 'Controls - How to use Timer without using timer control ' Declarations Private Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, _ ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long Private Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long Private mlngTimerID As Long ' Module code Public Sub StartTimer(lngInterval As Long) mlngTimerID = SetTimer(0, 0, lngInterval, AddressOf TimerCallBack) End Sub Public Sub TimerCallBack(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idEvent As Long, _ ByVal dwTime As Long) 'Do Something Here Range("A1").Value = Format$(Now, "HH:mm:ss") End Sub Public Sub StopTimer() KillTimer 0, mlngTimerID End Sub 'How can I call this function: 'Call StartTimer(1000)'To start the timer [1000 = 1 second] 'call StopTimer'To stop the timer |
Related posts:
- How to allow timer function without timer control
- How to create a self Closing Message Box
- How to use timer control for more than 65,535 milliseconds
- How to show/hide a label control at a particular interval using timer
- How to stretch image in a Picture Box Control
- How to make a beep program, in Visual Basic.. With Timer Settings!
- How to Make a Text Box Resizeable
- How to Display the Cursor’s coordinates of a Rich Text Box
- How to window caption to flash repeatedly
- How to visually click Command button through code