VISUAL BASIC_6
 

8. Project using Multiple Forms


Creating Forms:

The second form is  buttons.frm.   It contains an image box, two command buttons and a label.  The picture property of the image box is associated with a traffic icon which comes along with Windows 95.   The traffic icon contains three circles filled with red, green and amber colors respy.   By clicking the change button or any one of the colored circles, one colored circle can be highlighted.   The controls are arranged as shown in the figure 2 and the codes are entered as in the figure 2a in the code window of the buttons form.


 
                            Figure 2                                  

Private Sub ChangeSignal()

    ' Check to see what color the light is, and then change

    ' it to the next color.  The order is green, yellow,

    ' and then red.

    If imgGreen.Visible = True Then

        imgGreen.Visible = False

        imgYellow.Visible = True

    ElseIf imgYellow.Visible = True Then

        imgYellow.Visible = False

        imgRed.Visible = True

    Else

        imgRed.Visible = False

        imgGreen.Visible = True

    End If

End Sub

Private Sub cmdChange_Click()

    Call ChangeSignal        ' Call the ChangeSignal procedure.

End Sub

Private Sub cmdClose_Click()

   Unload Me            ' Unload this form.

End Sub

 

Private Sub imgGreen_Click()

    Call ChangeSignal        ' Call the ChangeSignal procedure.

End Sub

 

Private Sub imgRed_Click()

    Call ChangeSignal        ' Call the ChangeSignal procedure.

End Sub

 

Private Sub imgYellow_Click()

    Call ChangeSignal        ' Call the ChangeSignal procedure.

End Sub

 

Figure 2a


 

Copyright © 2001 Selfonline-Education. All rights reserved.