Share via

Timer Control for Visual Basic 6.0 Users

The Timer control in Visual Basic 6.0 is replaced by the Timer component in Visual Basic 2008. The names of some properties and events are different, and in some cases there are differences in behavior.

Conceptual Differences

The Visual Basic 6.0 Timer control is an actual control that is sited on a form at design time; however it is not visible at run time.

The Visual Basic 2008 Timer is a component that is added to the tray at design time; as a component it has no Parent property.


In addition to the Timer component, the .NET Framework also has two timer classes: Timer and Timer.

Interval Property

In Visual Basic 6.0, you can disable a Timer control by setting the Interval property to 0.

In Visual Basic 2008, the lower range for the Interval property is 1. If you set the interval to 0, it throws a run-time exception. The Visual Basic 2008 Timer component uses the Enabled property to allow you to disable or enable it.

Code Changes for the Timer Control

The following examples illustrate differences in coding techniques between Visual Basic 6.0 and Visual Basic 2008.

Code Changes for Starting and Stopping a Timer Control

The following code demonstrates how to enable and disable a Timer control at run time.

' Visual Basic 6.0
Public Function TimerOn(Interval As Integer)
    If Interval > 0 Then
        ' Start the timer.
        Timer1.Interval = Interval   
        ' Stop the timer.
        Timer1.Interval = 0 
    End If
End Function
' Visual BasicPublicSub TimerOn(ByRef Interval AsShort)
    If Interval > 0 Then        ' Start the timer.
        Timer1.Enabled = TrueElse        ' Stop the timer
        Timer1.Enabled = FalseEndIfEndSub

Timer Control Property and Event Equivalencies

The following table lists Visual Basic 6.0 properties and events, along with their Visual Basic 2008 equivalents. Those properties and events that have the same name and behavior are not listed.

This table provides links to topics explaining behavior differences. Where there is no direct equivalent in Visual Basic 2008, links are provided to topics that present alternatives.

Properties and Events

Visual Basic 6.0

Visual Basic 2008 Equivalent

Index property

New implementation. For more information, see Control Arrays for Visual Basic 6.0 Users

Interval property


The behavior of the Interval property has changed. For more information, see Timer Interval property behavior has changed.

Parent property

New implementation. The Timer is a component and cannot have a parent.

Timer event


Upgrade Notes

When a Visual Basic 6.0 application is upgraded to Visual Basic 2008, any Timer controls are upgraded to Windows Forms Timer components. If code is found that sets the Interval property to 0, an upgrade warning is added to your code.

See Also


Timer Component Overview (Windows Forms)