Timer Control


© Maxim Karetnikov
Articles in this Topic    Discussions in this Topic

In previous lessons, we have studied controls that are visually oriented. The Animated Button and Chart controls can be seen on the user's screen. The Timer control belongs to the type of control that is not visually oriented. The timer control is not intended to be something the user sees; it is a building block for your scripts. Any action that should occur after a precisely specified interval can be implemented with a timer and the code you can associate with a timer expiration. Perhaps you want a program to make a label on your Web page periodically change color and catch the user's attention. Maybe you want to refresh a Web page at regular intervals with a new advertising slogan. The possibilities are endless. All you need is a timer control, its object declaration, and some basic knowledge about its properties and event.

The basic properties of Timer control are given in the Table. enabled property determines whether the timer is turned off or on. If enabled is set to -1, which represents a true value in VBScript, the timer is in an enabled state. In other words, the timer is turned on and it's counting down the given time period. When the specified time period has gone by, the timer event procedure will be called if one exists. If enabled is set to 0, on the other hand, the timer is turned off. In this disabled state, no timer countdown occurs, and the timer event procedure will not be called.

Property

Description

progID IETimer.ocx
ClassID 59ccB4A0-727D-11CF-AC36-00AA00A47DD2
Enabled 0- turned off, -1- turned on
Interval Interval between timer events in milliseconds

The interval property specifies how much time must elapse between turning on the timer and calling the associated event procedure, if any. The interval property is so named because it defines the interval between timer events. This value must be specified in terms of milliseconds. A second has 1000 milliseconds, so to set the timer for 5 seconds, you would set the interval property to 5000.

The greatest amount of time that you can set for the timer interval property is about 64K seconds, or 65534 milliseconds. If you need to time a duration that lasts longer than 65 seconds, you have to write code that uses the shorter timer expiration event repeatedly to gauge when some longer period of time has elapsed. If the interval

Go To Page: 1 2 3


Post this Article to facebook Add this Article to del.icio.us! Digg this Article furl this Article Add this Article to Reddit Add this Article to Technorati Add this Article to Newsvine Add this Article to Windows Live Add this Article to Yahoo Add this Article to StumbleUpon Add this Article to BlinkLists Add this Article to Spurl Add this Article to Google Add this Article to Ask Add this Article to Squidoo


Here's the follow-up discussion on this article: View all related messages

1.   Jun 21, 2003 12:30 AM

-- posted by chsreeram





Join the latest discussions

For a complete listing of article comments, questions, and other discussions related to Maxim Karetnikov's VB Script topic, please visit the Discussions page.