Advertisement
2002VB Miscellaneous #20571

A Simple Long Delay Timer

A simple long delay timer. The VB Timer control is limited to 64k milli seconds, this short code extends that to near infinity in 6 lines of code. Heavily commented.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
Private Sub Timer1_Timer()
  
  'Set the interval of the timer.
  'Each time the timer event is called
  'subtract one from the tick.
  
  'Assuming 10000 interval with a 1440 tick,
  'this would give a delay of 4 hours.
  
  '10000 / 1000 = 10 *Milliseconds to Seconds
  '10 * 1440 = 14400 *Multiply by ticks
  '14400 / 60 = 240  *Seconds to minutes
  '240 / 60 = 4    *Minutes to hours
  
  'Allocate a static variable
  Static siTick As Integer
    
  'Check if variable greater then desired tick
  If siTick > 1440 Then
    
    '************ Do some code ************'
    
    'Start the ticker over
    siTick = 0
    
  'If not then add one to the tick
  Else
    siTick = siTick + 1
  End If
  
End Sub
Original Comments (3)
Recovered from Wayback Machine