Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.

Slides:



Advertisements
Similar presentations
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Advertisements

Using Multiple Forms! Creating a Splash Screen. Uses of Multiple Forms Includes: Dialog Boxes (appear often in Windows Programs) Splash Screen (a window.
Chapter 7: Sub and Function Procedures
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
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.
Excel and VBA Creating an Excel Application
Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 7 Multiple Forms, Modules,
VBA Modules, Functions, Variables, and Constants
Using Visual Basic 6.0 to Create Web-Based Database Applications
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 7- 1.
Slide 1 Forms v Parts of a form v Form: Program User Interface v Controls are contained inside forms v Control event handlers are contained inside forms.
Scope of Variables and Constants A Variable or Constant may exist and be Visible for an entire project, for only one form, or for only one procedure Therefore,
Multiple Document Interface (MDI) application
Promoting Code Reuse Often in programming, multiple procedures will perform the same operation IN OTHER WORDS – the same piece of code will do the same.
Scope of Variables and Constants A Variable or Constant may exist and be Visible for an entire project, for only one form, or for only one procedure Therefore,
Copyright © 2014 Pearson Education, Inc. Chapter 7 Multiple Forms, Modules, and Menus.
Chapter 9 Macros, Navigation Forms, PivotTables, and PivotCharts
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
05/09/ Introducing Visual Basic Sequence Programming.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Tutorial 11 Using and Writing Visual Basic for Applications Code
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/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 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.
CHAPTER SIX Reducing Program Complexity General Sub Procedures and Developer-defined Functions.
® Microsoft Access 2010 Tutorial 11 Using and Writing Visual Basic for Applications Code.
Using Arrays and File Handling
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
Multiple Forms, Container Controls, AddHandler This presentation is based on the Forms and ContainerControls VB Projects 1.
Chapter 2 More Controls Programming in C#. NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
 Application – another name for a program.  Interface – is what appears on the screen when the application is running.  Program Code – is instructions.
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
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.
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.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
INSERT BOOK COVER 1Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Getting Started with VBA for Microsoft Office 2010 by.
CHAPTER SIX Reducing Program Complexity General Sub Procedures and Developer-defined Functions.
Programming with Microsoft Visual Basic th Edition
6-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
CHAPTER THREE Representing Data: Constants and Variables.
Tutorial 81 Field, Record, Data File Field - a single item of information about a person, place, or thing Record - a group of related fields that contain.
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
Creating New Forms Projects can appear more professional when using different windows for different types of information. Select Add Windows Form from.
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 8 Multiple Forms, Modules, and Menus. Introduction This chapter demonstrates how to: – Add multiple forms to a project – Create a module to hold.
Multiple Forms and Menus
IS 350 Application Structure
Chapter 1: An Introduction to Visual Basic 2015
Working with Forms in Visual Basic
Using Procedures and Exception Handling
Variables and Arithmetic Operations
Chapter 6 Multiform Projects
Multiple Forms, Modules, and Menus
Lecture Set 11 Creating and Using Classes
Tonga Institute of Higher Education
Presentation transcript:

Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San Diego

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Ch6: Multiple Forms  Multiple forms  Show and Hide methods for forms  Standard code modules  Variable scope in multiform projects  An About Box form  Splash screen  Set the startup form

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Multiple Forms  Creating new forms  Adding and removing forms  Hide & Show methods  Load & Unload statements  Referring to objects in other forms –code in one form cannot “see” obj. in other forms –reference: FormName!ObjectName.property

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Multiple Forms  First form is startup form. –By default, it is the first one created –You can set startup form in Project, Properties  Create form: –Project, Add Form –Select form type  You can add a form to project from existing form

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Adding/Removing Forms  All the information in a form resides with the form: controls, properties, code, variables  Add existing form: Project, Add Form and then click the existing tab  Remove a form: Project, Remove File

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Hide and Show methods  You display a form with the show method: frmAbout.Show  General form is formname.Show –where style can be 1 (modal) or the default value 0 (nonmodal)  User must respond to Modal form & cannot click another form in same project  Hide a form: frmAbout. Hide

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Form Load & Activate Events  The first time a form is displayed, it triggers a form load event followed by a form activate event  Load calls the module into memory  Activate occurs when the form receives control  Subsequently, activate but not load events trigger when form is shown

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Unload/Load Statements (cont'd)  Only time you might want to load a form is when you want to load a form but display it later.  The Me keyword refers, always, to the currently active form: Unload Me Me.Hide

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Referring to Other Forms’ Objects  You can refer to txtName in another form called frmSummary this way: frmSummary!txtName = … or frmSummary!txtName.Font.Name =...  This implies that control names are unique within a form but need not be unique across forms.

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Standard Code Modules  Public procedures are“visible” to all forms  Public variables are visible to all forms  SCM has the extension.BAS  Create SCM: Project, Add Module  DIM variables in the code module are visible to all procedures in the module, but not to procedures in the form modules.

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Variables & Constants in Multi- form Projects  Scope of variables: –Local: available inside a procedure –Static: inside procedure, but remembered –Module level: available anywhere in a form –Global: available across forms--anywhere  Global variables declared with Public  Variable prefix naming conventions: m for module, g for global  Scope a variable as narrowly as possible

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill An About Box  Acts like a Windows Help|About box  Often displays information about the programmers, designers, and so on  An about box is simply a modal form with an OK button and label boxes displaying information  You can use VB’s About Dialog template

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill A Splash Screen  Splash screen displays while product loads  Create: Project, Add Form, then select Splash Screen  Splash screen loads first instead of main form  Place splash screen load statement in Sub Main procedure in Standard Code Module

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Setting the Startup Form/Proc.  By default, the first form you create in a project is the startup form  You can set the startup form in the Project Properties menu (Project menu)

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Hands on Programming Example  Programming example is a multi-form Coffee Sales example with these forms: –Splash screen –Main form –Summary form –About box  Main form called from splash screen

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Programming Hints  Make form run maximized window by setting the WindowState form property to 2-Maximized  In design time, close extra windows to maximize your view of form  Clicking a form's Close button halts execution

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Summary (1)  Projects can have unlimited # forms  First form displayed is the startup form  You can use forms from one project in another one  Show/Hide are form methods  Modal form requires a response; and, execution halts until response received

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Summary (2)  Load statement loads forms but does not display them  Me refers to currently active form  Refer to object in another form with form name as prefix  SCM contains public variables and public sub procedures that are global to project

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Summary (3)  Public can appear only in the General Declarations section of a module—place it in SCM only by convention  Static variables are local but with “memory”  Program execution can begin in a sub procedure called Main located in Standard Code Module