' Ch. 9 Demo 6
' Mr. Minich
' Purpose - using multiple forms in a VB project
' frmMain
Option Explicit
Private Sub mnuHelpAbout_Click()
frmAbout.Show vbModal
' By specifying vbModal, you are REQUIRING the user to close, unload, or hide this
' form before returning to the previous form.
End Sub
Private Sub mnuHelpInstructions_Click()
frmInstructions.Show vbModeless
' The Show method for a form will automatically load and show
' the form.
' vbModeless specifies that the user can leave the form displayed
' and still use other forms. Since vbModeless is the default argument
' for the Show method, it doesn't have to be specified. That is,
' frmInstructions.Show
' could be used above.
End Sub
Private Sub mnuFileExit_Click()
' exits project after unloading all forms
Dim frmForm As Form ' a form
For Each frmForm In Forms
Unload frmForm
Next
' You MUST use a For Each loop like this to properly end VB projects
' that contain multiple forms. Otherwise, a form could be left in
' the memory of the computer even after the program has been exited.
End Sub
' frmInstructions
Option Explicit
Private Sub cmdClose_Click()
Unload frmInstructions
' frmInstructions.Hide could be used but the form along
' with any graphics it contains
' would still be present in the
' computer's memory. However, if
' you unload a form, it takes longer
' for it to be loaded if the user
' shows it again.
End Sub
' frmAbout
' I added VB's template About Dialog window and deleted all event procedures except the following two:
Option Explicit
Private Sub cmdOK_Click()
Unload Me ' is equivalent to Unload frmAbout
End Sub
Private Sub Form_Load() ' to fill in this form, go to the Project/Project 1 Properties menu command
' and fill in the Title, Major version & Minor revision properties
Me.Caption = "About " & App.Title
lblVersion.Caption = "Version " & App.Major & "." & App.Minor & "." & App.Revision
lblTitle.Caption = App.Title
End Sub