Visual Basic - The Timer Interval Property Behaves Differently In VB .NET (VB .NET)

In VB 6, you could turn the Timer control on by setting the Interval property value to a number greater than 0 and you could turn it off by setting the value to 0, like so:

  • Timer1.Interval = 60
  • Timer1.Interval = 0

VB .NET will throw and exception if you set the Interval property to a value less than 1. To turn the Timer component on and off, you must use the Enabled property as shown below:

  • Timer1.Enabled = True
  • Timer1.Enabled = False

One other small note about the Timer Interval property, the maximum value is no longer 65,535 milliseconds. The .NET Timer can tick for more than 2.1 billion milliseconds (the maximum integer value). So if you have some reason for an application to wait a few weeks, the new .NET Timer should suit your needs just fine.

Go back