VISUAL BASIC_6
 

8. Project using Multiple Forms


Creating Forms:

The third form  is check.frm.   It contains a frame containing two option buttons, three independent option buttons, two labels and one command button.   The captions are given as in the figure 3 and positioned.   The code  window for this form is opened  and the codes are entered as shown in the figure 3a.

                                               Figure 3

' set up two string variables to hold the captions

Dim strComputer As String

Dim strSystem As String

 

Sub DisplayCaption()

    ' concatenate the caption with the two string

    ' variables.

    lblDisplay.Caption = "You selected a " & _

     strComputer & " running " & strSystem

End Sub

 

Private Sub cmdClose_Click()

    Unload Me   'unload the form

End Sub

 

Private Sub Form_Load()

    ' invoke a Click event in the default options

    ' to update the label caption

    opt486_Click

    optWin95_Click

End Sub

 

Private Sub opt486_Click()

    ' assign a value to the first string variable

    strComputer = "486"

    ' call the subroutine

    Call DisplayCaption

End Sub

 

Private Sub opt586_Click()

    ' assign a value to the first string variable

    strComputer = "Pentium"

    ' call the subroutine

    Call DisplayCaption

End Sub

 

Private Sub opt686_Click()

    ' assign a value to the first string variable

    strComputer = "Pentium Pro"

    ' call the subroutine

    Call DisplayCaption

End Sub

 

Private Sub optWin95_Click()

    ' assign a value to the second string variable

    strSystem = "Windows 95"

    ' call the subroutine

    Call DisplayCaption

End Sub

 

Private Sub optWinNT_Click()

    ' assign a value to the second string variable

    strSystem = "Windows NT"

    ' call the subroutine

    Call DisplayCaption

End Sub

 

     Figure 3a


 

Copyright © 2001 Selfonline-Education. All rights reserved.