The Timer Control

Another useful control is the Timer control. The timer works just the way the Visual Basic timer does. It supports an Interval property that takes as an argument the number of milliseconds between Time events. Listing 4-4 shows an example of a timer used to display a MsgBox after 5 seconds have elapsed. Figure 4-12 shows a sample of the output.

Listing 4-4.

The Timer control used in HTML code.

<HTML>
<HEAD>
<TITLE>Timer Control</TITLE>

<SCRIPT LANGUAGE="VBScript">
<!--
    Sub timer1_timer
        timer1.enabled=False 
        MsgBox "It has been 5 seconds!"
    End Sub
-->
</SCRIPT>

<OBJECT
    CLASSID="clsid:59CCB4A0-727D-11CF-AC36-00AA00A47DD2"
    ID=timer1
    >
    <PARAM NAME="Interval" VALUE="5000">
    <PARAM NAME="Enabled" VALUE="True">
</OBJECT>
    
</HEAD>
<BODY>
</BODY>
</HTML> 

Figure 4-12.

Sample output of the Timer control.

The timer is useful for adding a dynamic look and feel to your web page. Use it to change label captions or play music.

© 1996 by Scot Hillier. All rights reserved.