Copyright © 2014 Pearson Education, Inc. Chapter 7 Multiple Forms, Modules, and Menus.

Slides:



Advertisements
Similar presentations
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 7- 1 STARTING OUT WITH Visual Basic 2008 FOURTH EDITION Tony Gaddis.
Advertisements

Multiple Forms, Standard Modules, And Menus
Tutorial 8: Developing an Excel Application
110-H1 More VB Tools Creating a Menu: What is a menu? a group of (related) commands displayed at at the top of an application Top level menu Disabled command.
Chapter 5 Menus, Common Dialog Boxes, Sub Procedures, and Function Procedures Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved.
Chapter 6 Multiform Projects Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 7 Multiple Forms, Modules,
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 7- 1.
Multiple Forms & Procedures. Form Methods: –Show, Hide, Activate, Close Events: –Load, Activated, Closing, Closed.
Using the Visual Basic Editor Visual Basic for Applications 1.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Creating Menu. Objectives Create a menu system for a form –Create a menu –Create a menu titles –Create a menu items –Create a submenu –Modify menu –Edit.
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Chapter 8: String Manipulation
McGraw-Hill© 2007 The McGraw-Hill Companies, Inc. All rights reserved. 1-1.
05/09/ Introducing Visual Basic Sequence Programming.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Copyright 2007, Paradigm Publishing Inc. EXCEL 2007 Chapter 7 BACKNEXTEND 7-1 LINKS TO OBJECTIVES Record & run a macro Record & run a macro Save as a macro-
McGraw-Hill/Irwin Programming in Visual Basic 6.0 © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Update Edition Chapter 6 Multiple Forms.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
Microsoft Visual Basic 2008 CHAPTER NINE Using Arrays and File Handling.
Microsoft Visual Basic 2005 CHAPTER 9 Using Arrays and File Handling.
Multiple Forms, Standard Modules, And Menus
Multiple Forms and Standard Modules
Chapter 6 Understanding the Structure of an Application: Procedures, Modules, and Classes.
5-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
IE 411/511: Visual Programming for Industrial Applications
McGraw-Hill © 2009 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 5 Menus, Common Dialog Boxes, Sub Procedures, and Function Procedures.
Multiple Forms, Container Controls, AddHandler This presentation is based on the Forms and ContainerControls VB Projects 1.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Typing Application Introducing Keyboard Events, Menus, Dialogs and the Dictionary.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 2 Welcome Application Introducing the Visual Basic 2008 Express Edition IDE.
CTS130 Spreadsheet Lesson 4 Working with Cells, Columns, Rows, and Sheets.
Chapter 5 Menus, Common Dialog Boxes, and Methods Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
© Paradigm Publishing Inc. MICROSOFT WINDOWS XP MAINTAINING FILES AND CUSTOMIZING WINDOWS Section 2.
 Application – another name for a program.  Interface – is what appears on the screen when the application is running.  Program Code – is instructions.
Chapter 5 Menus, Common Dialog Boxes, Sub Procedures, and Function Procedures Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
McGraw-Hill © 2009 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 6 Multiform Projects.
Copyright © 2012 Pearson Education, Inc. Chapter 9 Classes and Multiform Projects.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 8 Debugging, Creating Executable Files, and Distributing a Windows Application.
Using Advanced Options Lesson 14 © 2014, John Wiley & Sons, Inc.Microsoft Official Academic Course, Microsoft Word Microsoft Word 2013.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
6-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Creating Menus Menu Bar – behaves like standard Windows menus Can be used in place of or in addition to buttons to execute a procedure Menu items are controls.
Chapter 5 Menus, Sub Procedures and Sub Functions Programming In Visual Basic.NET.
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Chapter 2 Introduction to Visual Basic Programming Visual Basic.NET.
Object-Oriented Application Development Using VB.NET 1 Chapter 2 The Visual Studio.NET Development Environment.
Compunet Corporation Programming with Visual Basic.NET Working with Menus and Dialog Boxes Week 14 Tariq Aziz and Kevin Jones.
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
Creating New Forms Projects can appear more professional when using different windows for different types of information. Select Add Windows Form from.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 6 Looping and Multiple Forms.
Chapter 7 Multiple Forms, Modules, and Menus. Section 7.2 MODULES A module contains code—declarations and procedures—that are used by other files in a.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Chapter 8. Copyright 2003, Paradigm Publishing Inc. CHAPTER 8 BACKNEXTEND 8-2 LINKS TO OBJECTIVES Delete, Move, Copy, and Paste Text Delete, Move, Copy,
Chapter 8 Multiple Forms, Modules, and Menus. Introduction This chapter demonstrates how to: – Add multiple forms to a project – Create a module to hold.
Chapter 7, Slide 1Starting Out with Visual Basic 3 rd Edition Chapter 7 Multiple Forms, Standard Modules, And Menus.
Multiple Forms and Menus
PictureBox, MessageBox, Multiple Forms, Splash Screens and Timers
Variables and Arithmetic Operations
Chapter 6 Multiform Projects
Multiple Forms, Modules, and Menus
Presentation transcript:

Copyright © 2014 Pearson Education, Inc. Chapter 7 Multiple Forms, Modules, and Menus

Copyright © 2014 Pearson Education, Inc. Topics 7.1 Multiple Forms 7.2 Modules 7.3 Menus 7.4 Focus on Problem Solving: Building the High Adventure Travel Agency Price Quote Application

Copyright © 2014 Pearson Education, Inc. Overview This chapter demonstrates how to: –Add multiple forms to a project –Create a module to hold procedures and functions –Create a menu system with commands and submenus –Create context menus that appear when the user right-clicks on an item

Copyright © 2014 Pearson Education, Inc. Multiple Forms 7.1

Copyright © 2014 Pearson Education, Inc. Windows Forms Applications Windows Forms applications are not limited to only a single form You may create multiple forms –To use as dialog boxes –Display error messages –And so on Windows Forms applications typically have one form called the startup form –Automatically displayed when the application starts –Assigned to the first form by default –Can be assigned to any form in the project

Copyright © 2014 Pearson Education, Inc. Form Files and Form Names Each form has a Name property –Set to Form1 by default Each form also has a file name –Stores the code associated with the form –Viewed in the Code window –Has the same name as the form –Followed by the.vb extension –Shown in the Solution Explorer window

Copyright © 2014 Pearson Education, Inc. Renaming an Existing Form File Always use the Solution Explorer window to change the file name and the form’s Name property will change automatically To rename a form file: –Right-click file name in Solution Explorer –Select Rename from the menu –Type the new name for the form –Be sure to keep the.vb extension

Copyright © 2014 Pearson Education, Inc. Adding a New Form to a Project To add a new form to a project: –Click PROJECT on the Visual Studio menu bar, and then select Add Windows Form... The Add New Item window appears –Enter the new Name in the Name text box –Click the Add button A new blank form is added to your project

Copyright © 2014 Pearson Education, Inc. Switching between Forms and Form Code To switch to another form: –Double-click the form’s entry in the Solution Explorer window To switch between forms or code: –Use the tabs along the top of the Designer window FormCodeFormCode

Copyright © 2014 Pearson Education, Inc. Removing a Form To remove a form from a project and delete its file from the disk: –Right-click the form’s entry in the Solution Explorer window –On the pop-up menu, click Delete To remove a form from a project but leave its file on disk: –Right-click the form’s entry in the Solution Explorer window –On the pop-up menu, click Exclude From Project –Or –Select the form’s entry in the Solution Explorer window –Click Project on the menu, and click Exclude From Project

Copyright © 2014 Pearson Education, Inc. Designating the Startup Form To make another form the startup form: –Right-click the project name in the Solution Explorer window –On the pop-up menu, click Properties, the properties page appears –Select the Application tab –Click the down arrow in the Startup Form drop-down list –Select a form from the list of available forms

Copyright © 2014 Pearson Education, Inc. Creating an Instance of a Form The form design is a class –It’s only a design or description of a form –Think of it like a blueprint A blueprint is a detailed description of a house A blueprint is not a house The form design can be used to create instances of the form –Like building a house from the blueprint To display a form, we must first create an instance of the form Public Class FormName End Class

Copyright © 2014 Pearson Education, Inc. Displaying a Form The first step is to create an instance of the form with the Dim statement –Here is the general format: ObjectVariable is the name of an object variable that references an instance of the form An object variable –Holds the memory address of an object –Allows you to work with the object ClassName is the form’s class name The following statement creates an instance of the ErrorForm form in memory: frmError variable references the ErrorForm object Statement does not cause the form to be displayed on the screen To display the form on the screen: –Use the object variable to invoke one of the form’s methods Dim ObjectVariable As New ClassName The prefix frm is used to indicate that the variable references a form Dim frmError As New ErrorForm

Copyright © 2014 Pearson Education, Inc. The ShowDialog and Show Methods If a modal form is displayed: –No other form in the application can receive the focus until the form is closed The ShowDialog method causes a form to be displayed as a modal form –Here is the general format: For example: If a modeless form is displayed: –The user is allowed to switch focus to another form while it is displayed The Show method causes a form to be displayed as a modeless form –Here is the general format: For example: ObjectVariable.ShowDialog() Dim frmError As New ErrorForm frmError.ShowDialog() ObjectVariable.Show() Dim frmError As New ErrorForm frmError.Show()

Copyright © 2014 Pearson Education, Inc. Closing a Form with the Close Method The Close method closes a form and removes its visual part from memory A form closes itself using the keyword Me For example: Causes the current instance of the form to call its own Close method, thus closing the form Me.Close() The keyword Me in Visual Basic is a special variable that references the currently executing object

Copyright © 2014 Pearson Education, Inc. The Hide Method The Hide method –Makes a form or control invisible –Does not remove it from memory –Similar to setting the Visible property to False A form uses the Me keyword to call its own Hide method For example: To redisplay a hidden form: – Use the ShowDialog or Show methods Tutorial 7-1 creates a simple application that has two forms Me.Hide()

Copyright © 2014 Pearson Education, Inc. More on Modal and Modeless Forms When a procedure calls the ShowDialog method –Display of a modal form causes execution of calling statements to halt until form is closed When a procedure calls the Show method –Display of a modeless form allows execution to continue uninterrupted statement frmMessage.ShowDialog() statement Halt! statement frmMessage.Show() statement Go! Tutorial 7-2 demonstrates the difference between modal and modeless forms

Copyright © 2014 Pearson Education, Inc. The Load Event The Load event is triggered just before the form is initially displayed Any code needed to prepare the form prior to display should be in the Load event If some controls should not be visible initially, set their Visible property in the Load event Double-click on a blank area of the form to set up a Load event as shown below Complete the template with the statements you wish the procedure to execute Private Sub MainForm_Load(…) Handles MyBase.Load End Sub

Copyright © 2014 Pearson Education, Inc. The Activated Event The Activated event occurs when the user switches to the form from another form or application To create an Activated event handler, follow these steps: 1.Select the form in the Designer window 2.Select the Events button in the Properties window toolbar 3.Double-click the Activated event name in the Properties window After completing these steps, a code template for the event handler is created in the Code window

Copyright © 2014 Pearson Education, Inc. The FormClosing Event The FormClosing event is triggered as the form is being closed, but before it has closed The event can be used to ask the user if they really want the form closed To create an FormClosing event handler, follow these steps: 1.Select the form in the Designer window 2.Select the Events button in the Properties window toolbar 3.Double-click the FormClosing event name in the Properties window After completing these steps, a code template for the event handler is created in the Code window

Copyright © 2014 Pearson Education, Inc. The FormClosed Event The FormClosing event occurs after a form has closed The event can be used to execute code immediately after a form has closed To create an FormClosed event handler, follow these steps: 1.Select the form in the Designer window 2.Select the Events button in the Properties window toolbar 3.Double-click the FormClosed event name in the Properties window After completing these steps, a code template for the event handler is created in the Code window You cannot prevent a form from closing with the FormClosed event handler. You must use the FormClosing event handler to prevent a form from closing.

Copyright © 2014 Pearson Education, Inc. Accessing Controls on a Different Form Once you have created an instance of a form, you can access controls on that form in code –The following code shows how you can Create an instance of a form Assign a value to the form’s label control’s Text property Display the form in modal style Tutorial 7-3 demonstrates accessing controls on a different form Dim frmGreetings As New GreetingsForm frmGreetings.lblMessage.Text = "Good day!" frmGreetings.ShowDialog()

Copyright © 2014 Pearson Education, Inc. Class-Level Variables in a Form Class-level variables are declared Private by the Dim statement Private variables are not accessible by code in other forms Use the Public keyword to make a class-level variable available to methods outside the class Explicitly declare class-level variables with the Private keyword to make your source code more self-documenting Public dblTotal As Double ' Class-level variable Dim dblTotal As Double ' Class-level variable Private dblTotal As Double ' Class-level variable

Copyright © 2014 Pearson Education, Inc. Using Private and Public Procedures in a Form Procedures, by default, are Public They can be accessed by code outside their form To make a procedure invisible outside its own form, declare it to be Private You should always make the procedures in a form private –Unless you specifically want statements outside the form to execute the procedure

Copyright © 2014 Pearson Education, Inc. Using a Form in More Than One Project After a form has been created and saved to a file, it may be used in other projects Follow these steps to add an existing form to a project: 1.With the receiving project open in Visual Studio, click PROJECT on the menu bar, and then click Add Existing Item 2.The Add Existing Item dialog box appears 3.Locate the form file that you want to add to the project, select it and click the Open button A copy of the form is now added to the project

Copyright © 2014 Pearson Education, Inc. Modules 7.2

Copyright © 2014 Pearson Education, Inc. What is a Module? A module is a Visual Basic file that contains only code –General purpose procedures, functions, and declarations of variables and constants –Can be accessed by all forms in the same project –No event handlers –Stored in files that end with the.vb extension –Appears in the Solution Explorer window along with entries for the project’s form files

Copyright © 2014 Pearson Education, Inc. Module Names and Module Files A module –begins with a Module statement –ends with an End Module statement Here is the general format: ModuleName is the name of the module –Can be any valid identifier that describes its purpose Code is stored in a file that is named with the.vb extension Normally, the name of the file is the same as the name of the module Module ModuleName [Module Contents] End Module

Copyright © 2014 Pearson Education, Inc. Module Example The following code shows the contents of a module named RetailMath Procedures, functions, and declarations can be declared as Private, which means that they can be accessed only by code in the same module Module RetailMath ' Global constant for the tax rate Public Const decTAX_RATE As Decimal = 0.07D ' The SalesTax function returns the sales tax on a purchase. Public Function SalesTax(ByVal decPurchase As Decimal) As Decimal Return decPurchase * decTAX_RATE End Function End Module

Copyright © 2014 Pearson Education, Inc. Adding a Module Follow these steps to add a module to a project: 1.Click PROJECT on the menu bar and then click Add Module. The Add New Item window appears 2.Change the default name that appears in the Name text box to the name you wish to give the new module file, and be sure to keep the.vb extension 3.Click the Add button A new empty module will be added to your project –The module is displayed in the Code window –An entry for the module appears in the Solution Explorer window

Copyright © 2014 Pearson Education, Inc. Module-Level Variables A module-level variable is a variable that is declared inside a module, but not inside a procedure or function The same rules about the scope of class-level variables in a form apply to module-level variables in a module Variables with module scope are declared with Dim or Private –Accessible to any function or procedure in the module –Not accessible to statements outside of the module A global variable is declared with the Public keyword –Accessible to any statement in the application –Some programmers prefix global variables with g_ Tutorial 7-4 examines an application that uses a module Public g_decPurchaseAmount As Decimal ' Global variable

Copyright © 2014 Pearson Education, Inc. Using a Module in More Than One Project It is possible to use more than one module in a project Follow these steps to add an existing standard module to a project: 1.Click PROJECT on the menu bar, and then click Add Existing Item. The Add Existing Item dialog box appears 2.Use the dialog box to locate the module file you want to add to the project. When you locate the file, select it and click the Open button The module is now added to the project

Copyright © 2014 Pearson Education, Inc. Menus 7.3

Copyright © 2014 Pearson Education, Inc. Menu Systems A menu system is a collection of commands organized in one or more drop- down menus –Commonly used when an application has several options for the user to choose from The menu designer allows you to visually create a custom menu system – For any form in an application

Copyright © 2014 Pearson Education, Inc. Components of a Menu System Each drop-down menu has a menu name Each drop-down menu has a list of actions or menu commands that can be performed Some commands may lead to a submenu

Copyright © 2014 Pearson Education, Inc. Components of a Menu System Actions may be performed using a key or key combination called a shortcut key A checked menu command toggles between the checked (if on) and unchecked (if off) states A separator bar helps group similar commands

Copyright © 2014 Pearson Education, Inc. MenuStrip Control A MenuStrip control adds a menu to a form –Double-click on the MenuStrip icon in the Menus & Toolbars section of the Toolbox The MenuStrip control is displayed in the component tray (bottom of Design window) A MenuStrip can have many ToolStripMenuItem objects: –Each represents a single menu command –Name property - used by VB to identify it –Text property – text displayed to the user

Copyright © 2014 Pearson Education, Inc. How to Use the Menu Designer Select the MenuStrip Control The menu designer appears on the form in the location that the menu system will appear

Copyright © 2014 Pearson Education, Inc. ToolStripMenuItem Object Names It is recommended that you change the default value of the Name property so that it –Begins with the mnu prefix –Reflects the Text property and position in the menu hierarchy mnuFile mnuFileSave mnuFilePrint mnuFileExit

Copyright © 2014 Pearson Education, Inc. Shortcut Keys Combination of keys that cause a menu command to execute –Ctrl + C to copy an item to the clipboard –Set with the ShortcutKeys property –Displayed only if the ShowShortcut property is set to True

Copyright © 2014 Pearson Education, Inc. Checked Menu Items Turns a feature on or off –For example, an alarm for a clock To create a checked menu item: –Set CheckOnClick property to True Set Checked property to True if feature should be on when the form is initially displayed If mnuSettingsAlarm.Checked = True Then MessageBox.Show("WAKE UP!") End If

Copyright © 2014 Pearson Education, Inc. Disabled Menu Items A menu item is grayed out (disabled) with the Enabled property, for example: –Paste option is initially disabled and only enabled after something is cut or copied –Code initially disables the Paste option –Following a cut or copy, Paste is enabled mnuEditPaste.Enabled = False mnuEditPaste.Enabled = True

Copyright © 2014 Pearson Education, Inc. Separator Bars Right-click menu item, select Insert Separator –A separator bar will be inserted above the menu item Or type a hyphen (-) as a menu item’s Text property

Copyright © 2014 Pearson Education, Inc. Submenus When selecting a menu item in the menu designer, a Type Here box appears to the right –Begin a submenu by setting up this menu item If a menu item has a submenu, a solid right- pointing arrow will be shown

Copyright © 2014 Pearson Education, Inc. Inserting, Deleting, And Rearranging Menu Items To insert a new menu item –Right-click an existing menu item –Select Insert then MenuItem from pop-up menu –A new menu item will be inserted above the existing menu item To delete a menu item –Right-click on the item –Choose Delete from the pop-up menu –Or select the menu item and press the Delete key To rearrange a menu item –Simply select the menu item in the menu designer and drag it to the desired location

Copyright © 2014 Pearson Education, Inc. ToolStripMenuItem Click Event Menus and submenus require no code Commands must have a click event procedure –Double-click on the menu item –Event procedure created in the Code window –Programmer supplies the code to execute Suppose a menu system has a File menu with an Exit command named mnuFileExit Private Sub mnuFileExit_Click(...) Handles mnuFileExit.Click ' Close the form. Me.Close() End Sub

Copyright © 2014 Pearson Education, Inc. Standard Menu Items Most applications to have the following menu items –File as the leftmost item on the menu strip Access key Alt + F –An Exit command on the File menu Access key Alt + X Shortcut key Alt + Q (optional) –Help as the rightmost item on the menu strip Access key Alt + H –An About command on the Help menu Access key Alt + A Displays an About box Tutorial 7-5 demonstrates how to build a simple menu system

Copyright © 2014 Pearson Education, Inc. Context Menus A context menu, or pop-up menu, is displayed when the user right- clicks a form or control To create a context menu –Double-click the ContextMenuStrip icon in the Toolbox window –A ContextMenuStrip control appears in the component tray –Change the ContextMenuStrip control’s default Name property –Add menu items with the menu designer –Create click event procedures for the menu items –Associate the context menu with a control –Set the control’s ContextMenuStrip property to the name of the ContextMenuStrip control

Copyright © 2014 Pearson Education, Inc. Focus on Problem Solving: Building the High Adventure Travel Agency Price Quote Application 7.4

Copyright © 2014 Pearson Education, Inc. Overview The High Adventure Travel Agency offers the following vacation packages for thrill-seeking customers –Scuba Adventure: This package provides six days at a Caribbean resort with scuba lessons The price for this package is $3,000 per person. –Sky Dive Adventure: This package provides individual sky diving lessons during a six-day vacation at a luxury lodge The price for this package is $2,500 per person –The travel agency gives a 10% discount for groups of five or more You’ve been asked to create an application to calculate the charges for each package

Copyright © 2014 Pearson Education, Inc. Forms and Modules The MainForm form –Is the application’s startup form –Provides a menu that allows the user to select one of the vacation packages The ScubaForm form –Calculates the price of a scuba adventure travel package The SkyDiveForm form –Calculates the price of a sky dive adventure travel package The PriceCalcModule module –Contain global constants and a function that both the ScubaForm and SkyDiveForm forms will use to calculate discounts

Copyright © 2014 Pearson Education, Inc. The MainForm Form

Copyright © 2014 Pearson Education, Inc. The MainForm Menu System

Copyright © 2014 Pearson Education, Inc. The ScubaForm Form

Copyright © 2014 Pearson Education, Inc. The SkyDiveForm Form

Copyright © 2014 Pearson Education, Inc. The PriceCalcModule Module Module PriceCalcModule ' Global constants Public Const g_intMINIMUM_FOR_DISCOUNT As Integer = 5 Public Const g_decDISCOUNT_PERCENTAGE As Decimal = 0.1D ' The DiscountAmount function accepts a package total ' as an argument and returns the amount of discount ' for that total. Public Function DiscountAmount(ByVal decTotal As Decimal) As Decimal Dim decDiscount As Decimal ' To hold the discount ' Calculate the discount. decDiscount = decTotal * g_decDISCOUNT_PERCENTAGE ' Return the discount. Return decDiscount End Function End Module