Chapter 6' Multiple Forms - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

Chapter 6' Multiple Forms

Description:

A Splash Screen. A screen displayed while a program is loading. Create your own Splash screen by creating a new Splash screen form ... – PowerPoint PPT presentation

Number of Views:34
Avg rating:3.0/5.0
Slides: 11
Provided by: faculty46
Category:

less

Transcript and Presenter's Notes

Title: Chapter 6' Multiple Forms


1
Chapter 6. Multiple Forms
  • Form is window
  • Startup form is the first form to be executed
  • The form created in the first time
  • From the Sub Main
  • In the Project Properties
  • Creating New Form
  • Add Form from the Project menu
  • Add Form button on the toolbar

2
  • Adding the existing forms
  • From the Project menu
  • Click the Existing tab and Open the file
  • Deleting the existing forms
  • Choose Remove File form the Project menu
  • Right-click on the filename and choose Remove
    Filename
  • The Show Method
  • FormName.Show Style
  • frmSummary.Show 1 modal style
  • frmSummary.Show vbModal
  • frmSummary.Show vbModeless
  • frmSummary.Show modeless style

3
  • The Hide Method
  • FormName.Hide
  • frmSummary.Hide
  • The Load Statement
  • Load FormName
  • Load frmSummary
  • The Unload Statement
  • Unload FormName
  • Unload frmSummary
  • Show and Load
  • Show method loads and displays the form
  • Load method only loads but doesnt display

4
  • Hide and Unload
  • Hide method hides the form from the screen, but
    the form still resides on the memory
  • Unload method unloads the form from the memory
  • The Me Keyword
  • Unload Me Unload the form that is currently
    executing code
  • Me.Hide
  • Referring to Objects on a Different Form
  • FormName.ObjectName.Property
  • frmSummary.lblTotalAmount.Caption mcurTotal
  • frmSummary.Show vbModal

5
Standard Code Modules
  • To use the procedure in multiple forms
  • .bas
  • Add Module command on the Project menu
  • Same as Form module
  • Any Dimmed variables or constants in the General
    Declarations section of a standard code module
    are visible to all the procedures in that module,
    but not to the procedures in the form module(s).

6
Variables and Constants in Multiple-Form Projects
  • Scope of variables and constants
  • Local level
  • Global level
  • Module level
  • Static (procedure level)
  • Retain the value for the life of the project
  • Static Identifier As DataType
  • Static intPersonCount As Integer

7
  • Guidelines for Declaring Variables and Constants
  • Place all local declarations at the top of a
    procedure
  • Use named constants for any value that doesnt
    change during program execution
  • Keep the scope of variables and constants as
    narrow as possible
  • Consider making variables and constants local if
    possible
  • If you need to keep the value of a variable for
    multiple executions of a procedure, but dont
    need the variable in any other procedure, make it
    Static
  • If you need to use a variable both in a procedure
    and also in a second procedure called by the
    first procedure, declare the variable as local
    and pass it as an argument
  • If you need to use a variable in multiple
    procedures, such as to add to the variable in one
    procedure and to display it in another, use
    module-level variable
  • Finally, if you really need the value of a
    variable in more than one form, make it global.
    Keep your Public declarations in a standard code
    module.

8
An About Box
  • Help/About
  • The name and version of the project
  • Information about the programmer or company
  • Create your own About box by creating a new form
  • Use VBs About Dialog template to create a new
    About box
  • Figure 6.7, Figure 6.8, and Figure 6.9

9
A Splash Screen
  • A screen displayed while a program is loading
  • Create your own Splash screen by creating a new
    Splash screen form
  • Use VBs Splash screen template to create a new
    Splash screen form
  • It can make a large application appear to load
    and run faster, since something appears on the
    screen while the rest of the application loads
  • Figure 6.10 and Figure 6.11

10
Creating of Startup Form
  • Coding the Standard Code Module
  • Sub Main()
  • frmSplash.Show vbModeless
  • Load frmMain
  • End Sub
  • Coding the Splash Screen Event Procedure
  • Private Sub cmdClose_Click()
  • Unload Me
  • frmMain.Show vbModal
  • End Sub
  • Setting the Startup Form or Procedure
  • The default is the first form created in a
    project
  • Choose one of the projects forms or Sub Main
    from the project properties
Write a Comment
User Comments (0)
About PowerShow.com