Timers execute code after a period of time.

A Timer is started by a call to the SetTimer Function and stopped by a call to KillTimer.

The Api declarations for VBA6:

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


  • hWnd: the Handle of the parent window; if hWnd was set to '0', nIDEvent will be ignored
  • nIDEvent: the Timers ID; usually 'ID_TIMER1', 'ID_TIMER2', etc.; will be ignored, if hWnd = 0
  • uElapse: the time period in milliseconds between two successive WM_TIMER - Events
  • lpTimerFuc: the address of the TimerProc procedure

If you start a Timer without passing a parent window's handle, use the return value from SetTimer as the ID when calling KillTimer.

The same program may use several timers in parallel, distinguished by their ID.

A well behaved program should stop all timers before ending. Otherwise Catia and/or Windows will show 'Erratic behaviour'.


Go to top