Your project is now complete. Save bytecomp.alx and open bytecomp.htm in the Internet Explorer. Test the animation by selecting products and watching their icons move. Make sure that the total is updated as products are selected. Also test the right mouse button support, and check the data validation routine for the credit card number. Figure 9-24 (page 384) shows the completed order form in action, as well as products selected for purchase, the total cost, and the message box that is displayed if you right-click on the modem image. Listing 9-1 (page 384) shows the complete, commented VBScript code for the project.
Figure 9-24.
The completed order form in action.
<SCRIPT LANGUAGE="VBScript">
`Variable for total purchase price
Dim intTotal
intTotal=0
`Variables for storing the starting Left coordinates
`for each product image
Dim dblFloppy
Dim dblHardDrv
Dim dblCDROM
Dim dblMonitor
Dim dblKeyboard
Dim dblMouse
Dim dblModem
Dim dblJoystick
dblFloppy=154
dblHardDrv=154
dblCDROM=154
dblMonitor=154
dblKeyboard=154
Sub btnKeyboard_Click
tmrBytes.Enabled=True
If btnKeyboard.Value=True Then
intTotal=intTotal+125
Else
intTotal=intTotal-125
End If
lblTotal.Caption="$" & intTotal & ".00"
End Sub
Sub btnMouse_Click
tmrBytes.Enabled=True
If btnMouse.Value=True Then
intTotal=intTotal+60
Else
intTotal=intTotal-60
End If
lblTotal.Caption="$" & intTotal & ".00"
End Sub
Sub btnModem_Click
tmrBytes.Enabled=True
If btnModem.Value=True Then
intTotal=intTotal+150
Else
intTotal=intTotal-150
End If
lblTotal.Caption="$" & intTotal & ".00"
End Sub
Sub btnJoystick_Click
tmrBytes.Enabled=True
If btnJoystick.Value=True Then
intTotal=intTotal+35
Else
intTotal=intTotal-35
End If
lblTotal.Caption="$" & intTotal & ".00"
End Sub
Sub tmrBytes_Timer
`Author: New Technology Solutions, Inc.
`Purpose: Call Animate routine for each image
`6/22/96 Original
Call Animate(btnFloppy,imgFloppy,dblFloppy)
Call Animate(btnHardDrv,imgHardDrv,dblHardDrv)
Call Animate(btnCDROM,imgCDROM,dblCDROM)
Call Animate(btnMonitor,imgMonitor,dblMonitor)
Call Animate(btnKeyboard,imgKeyboard,dblKeyboard)
Call Animate(btnMouse,imgMouse,dblMouse)
Call Animate(btnModem,imgModem,dblModem)
Call Animate(btnJoystick,imgJoystick,dblJoystick)
End Sub
Sub Animate(MyButton,MyImage,MyStart)
`Author: New Technology Solutions, Inc.
`Purpose: Animate an image control
`6/22/96 Original
MyImage.ZOrder 1
If MyButton.Value=True and MyImage.Left<MyStart+240 Then
MyImage.Left=MyImage.Left+20
End If
If MyButton.Value=False and MyImage.Left>=MyStart+20 Then
MyImage.Left=MyImage.Left-20
End If
End Sub
`MouseDown events are used to supply
`additional product information when
`the right mouse button is clicked
Sub imgFloppy_MouseDown(Button,Shift,X,Y)
If Button=2 Then
MsgBox "1.44MB Drive and Ten Disks",64,"ByteComp"
End If
End Sub
Sub imgHardDrv_MouseDown(Button,Shift,X,Y)
If Button=2 Then
MsgBox "1GB Internal IDE Drive",64,"ByteComp"
End If
End Sub
Sub imgCDROM_MouseDown(Button,Shift,X,Y)
If Button=2 Then
MsgBox "4X IDE CD-ROM Drive",64,"ByteComp"
End If
End Sub
Sub imgMonitor_MouseDown(Button,Shift,X,Y)
If Button=2 Then
MsgBox "14-Inch VGA Monitor",64,"ByteComp"
End If
End Sub
Sub imgKeyboard_MouseDown(Button,Shift,X,Y)
If Button=2 Then
MsgBox "128-Key Ergonomic Keyboard",64,"ByteComp"
End If
End Sub
Sub imgMouse_MouseDown(Button,Shift,X,Y)
If Button=2 Then
MsgBox "Two-Button Serial Mouse",64,"ByteComp"
End If
End Sub
Sub imgModem_MouseDown(Button,Shift,X,Y)
If Button=2 Then
MsgBox "28.8 Internal Modem",64,"ByteComp"
End If
End Sub
Sub imgJoystick_MouseDown(Button,Shift,X,Y)
If Button=2 Then
MsgBox "Aviation-Style Joystick",64,"ByteComp"
End If
End Sub
Sub txtCardNumber_KeyPress(KeyASCII)
`Author: New Technology Solutions, Inc.
`Purpose: Validate credit card entry
`6/22/96 Original
txtCardNumber.Locked=True
If KeyASCII=8 Then txtCardNumber.Locked=False
If KeyASCII=45 Then txtCardNumber.Locked=False
If KeyASCII>47 and KeyASCII<58 Then
txtCardNumber.Locked=False
End If
End Sub
</SCRIPT>