ISM 3230 Introduction to Programming
 Chapter 6: Multiple Forms
Chapter 6 Student Learning OBJECTIVES:

Upon completion of this chapter, you will be able to

      1. Create a project with multiple forms.
      2. Use the Show and Hide methods to display and hide forms.
      3. Create procedures that are accessible from multiple form modules.
      4. Differentiate between variables that are global to a project and those visible only to a form.
      5. Use a form to create an About box.
      6. Add a splash screen to your project.
      7. Set the startup form or Sub Main to start project execution.

 

Multiple Forms

Adding/Removing Forms

Hide and Show methods

frmAbout.Show

frmAbout.Hide

Load and Unload statements

Show vs. Load

Form Load vs. Form Activate Events

For example:

Unload Me

Me.Hide

Referring to Other Forms’ Objects

frmSummary!txtName =

or frmSummary!txtName.Font.Name = ...

Standard Code Modules (SCM)

You place in the Standard Code Module (SCM) any procedures or variables referenced by more than one form.

Public

Variables and Constants in Multi-form Projects

Global Variables

Public gcurTotalSalary as Currency 'global variable

Public Const gcurTAX_RATE as Single = .082 'global constant

Dim mcurMySalary as Currency 'module-only variable

Static Variables

Private Sub Something()

Static intCount as Integer 'initialized to 0 once

intCount = intCount + 1 'remembered across invocations

···

End Sub


Variable Declaration Guidelines:


An About Box

Here’s an example "About" box

The VB About Dialog box template makes use of the Project's properties. If you carefully fill them in, you can access the properties as variables:

A Splash Screen

Private Sub Main()

frmSplash.Show 'load and display splash screen

Load frmMain 'load but don't display main form

End Sub

Private Sub cmdClose_Click()

Unload me 'unload the splash screen

frmMain.Show 'show the main form

End Sub

Setting the Startup Form

Hands on Programming Example

 

Programming Hints


Chapter Summary:

PROPERTIES

 

METHODS

 

STATEMENTS

 

KEYWORDS

ControlBox

 

Hide

 

Load

 

Me

MinButton

 

Show

 

Unload

   

MaxButton

     

Public

   

WindowState

     

Public Const

   
       

Static