6-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.

Slides:



Advertisements
Similar presentations
Visual Basic 2010 How to Program. © by Pearson Education, Inc. All Rights Reserved.2.
Advertisements

Visual Basic 2010 How to Program Reference: Instructor: Maysoon Bin Duwais slides Visual Basic 2010 how to program by Deitel © by Pearson Education,
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,
Using Visual Basic 6.0 to Create Web-Based Database Applications
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 7- 1.
CVEV 118/698 Visual Basic Lecture 3 Prof. Mounir Mabsout Elsa Sulukdjian Walid El Asmar.
Multiple Forms & Procedures. Form Methods: –Show, Hide, Activate, Close Events: –Load, Activated, Closing, Closed.
Using the Visual Basic Editor Visual Basic for Applications 1.
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,
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,
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Copyright © 2014 Pearson Education, Inc. Chapter 7 Multiple Forms, Modules, and Menus.
Chapter 2 –Visual Basic, Controls, and Events
Chapter 9 Macros, Navigation Forms, PivotTables, and PivotCharts
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter One An Introduction to Visual Basic 2010.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
McGraw-Hill© 2007 The McGraw-Hill Companies, Inc. All rights reserved. 1-1.
A First Program Using C#
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Microsoft Visual Basic 2005: Reloaded Second Edition
XP New Perspectives on Microsoft Office Access 2003 Tutorial 11 1 Microsoft Office Access 2003 Tutorial 11 – Using and Writing Visual Basic for Applications.
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.
Using Arrays and File Handling
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.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 21 Fields and Forms.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 4 I Need a Tour Guide.
Chapter 5 Menus, Common Dialog Boxes, and Methods Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Visual Studio.NET Part 2 dbg --- Using the Integrated Development Environment.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
 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.
OCC Network Drives  H:\  P:\ 
Chapter 2 –Visual Basic, Controls, and Events
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.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
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.
Lecture Set 2 Part A: Creating an Application with Visual Studio – Solutions, Projects, Files 8/10/ :35 PM.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Object-Oriented Programming: Inheritance and Polymorphism.
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.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
Chapter 2 - VB 2008 by Schneider1 Chapter 2 –Visual Basic, Controls, and Events 2.1 An Introduction to Visual Basic 2.2 Visual Basic Controls 2.3 Visual.
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.
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Using Macros Lesson.
Chapter 8 Multiple Forms, Modules, and Menus. Introduction This chapter demonstrates how to: – Add multiple forms to a project – Create a module to hold.
IS 350 Application Structure
Chapter 1: An Introduction to Visual Basic 2015
Using Procedures and Exception Handling
Chapter 6 Multiform Projects
CIS16 Application Development Programming with Visual Basic
Lecture Set 11 Creating and Using Classes
Object-Oriented Programming: Inheritance and Polymorphism
Presentation transcript:

6-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf

Multiform Projects Chapter 6 6 McGraw-Hill© 2006 The McGraw-Hill Companies, Inc. All rights reserved.

6-3 Objectives Include multiple forms in an application Use templates to create splash screens and about boxes Use the Show, ShowDialog, and Hide methods to display and hide forms Understand the various form events and select the best procedure for your code Declare variables with the correct scope and access level for multiform projects

6-4 Using Multiple Forms Projects can appear more professional when using different windows for different type of information The first form a project displays is called the startup form Projects can contain as many forms as desired

6-5 Creating New Forms Select Add Windows Form from the Project menu and select from many installed templates

6-6 Switching Between Forms (1 of 2) In design time there are several ways to switch between forms: Solution Explorer window-select a form name and click the View Designer button or the View Code button Double-clicking a form name opens the form in designer Easiest way is to use the tabs at the top of the Document window that appear when the form is displayed Each form is a separate file and a separate class

6-7 Switching Between Forms (2 of 2) Using Tabs Selecting from drop down list

6-8 Adding Existing Form Files to a Project Forms may be used in more than one project-an existing form maybe used in a new project Each form and information for the form is saved as three separate files: Code procedures Visual interface Property settings for the controls To add an existing form to a project use the Add Existing Item command on the Project menu Select only one filename: FormName.vb; all three files are automatically copied into the project folder

6-9 Removing Forms from a Project Select the file name in the Solution Explorer of the file to be removed Either click the Delete key or right-click on the filename to and choose Delete form the context menu Additional option is to choose Exclude from project to remove the form from the project but not delete the files

6-10 An About Box (1of 2) One popular type of form in a project is an About box - found in most Windows programs under Help/About Usually provides the name and version of the program and information about the programmer or company Users can create About boxes by creating a new form and entering the information in labels All Windows controls can be used on this form

6-11 An About Box (2 of 2)

6-12 Using the About Box Template Visual Studio’s About Box template can be used to create a new About box Choose Add Windows Form from the Project menu and select About Box

6-13 Setting Assembly Information Users can manually set the Text properties of the controls --OR-- Open the Project Designer from Project/ProjectName Properties or double-click the My Project in the Solution Explorer Click the Assembly Information button and fill in the desired information in the Assembly Information dialog box

6-14 Assembly Information Dialog Box

6-15 A Splash Screen The initial screen containing a logo or window that is seen while a program is loading Professional applications use splash screens to tell the user that the program is loading or starting Makes a large application appear to load and run faster since something is displaying on the screen while the rest of the application loads

6-16 Splash Screen Example

6-17 Using the Splash Screen Template Visual Studio contains splash screen templates Select Project/Add New Item to display the Add new item dialog box and choose Splash Screen Modify the form to fit current needs A splash form created using the Splash Screen template

6-18 Making the Splash Form Display First Display the Project Designer from the Project menu and set the Splash screen drop-down list to the created splash screen Do not change the setting for Startup object or Shutdown mode Then the project is run, the splash screen should display while the startup form is loading and then disappear At times the startup forms loads so quickly that it is nearly impossible to see the splash screen

6-19 Setting the Splash Screen Example Set the Splash screen drop- down list to the new form in the Project Designer

6-20 Showing a Form New forms are displayed in response to a user clicking a button or a menu item In the event procedure for the button or menu item use either the Show method or ShowDialog method to display the new form

6-21 Modal versus Modeless Forms Show method displays a form as modeless-means that both forms are open and the user can navigate from one form to the other ShowDialog method displays a new form as modal - the user must respond to the form in some way, usually by clicking a button No other program code can execute until the user responds to and hides or closes the modal form With a modeless form the user may switch to another form in the project without responding to the form

6-22 Show Method General Form Example The Show method creates a form object from the specified class and displays it modelessly-the formName is the name of the form to be displayed formName.Show () summaryForm.Show ()

6-23 ShowDialog Method General Form Example Use the ShowDialog method when the user is wanted to notice, respond to, and close the form before proceeding with the application-this code is generally placed in a menu item or a button’s click even procedure formName.ShowDialog () summaryForm.ShowDialog ()

6-24 Hiding or Closing a Form The Close method behaves differently for a modeless form compared to a modal form Modeless-Close destroys the form instance and removes it from memory Modal-the form is only hidden Choosing a form’s Hide method sets the form’s Visible property to False and keeps the form instance in memory ready to be re-displayed An example would be for form with instructions or Help text

6-25 Hide Method General Form Example formName.Hide() summaryForm.Hide()

6-26 Responding to Form Events Two primary events that code might be needed for are: FormName.Load-form loaded into memory FormName.Activated-occurs when control is passed to form First time a form is shown in an application the form generates both the Load and Activated events If a form is displayed multiple times, initializing steps can be placed into the Activated event procedure; same for setting the focus in a particular place on a new form

6-27 The Sequence of Form Events LoadOccurs before the form is displayed for the first time-usually happens only once ActivateOccurs each time the form is shown PaintOccurs each time any portion of the form is redrawn DeactivateOccurs when the form is no longer the active form FormClosingOccurs as the form is about to close FomClosedOccurs after the form is closed

6-28 Writing Event Procedures From the Code Editor In the Editor, drop down the Class Name list and choose the entry that shows the events for the selected form In the Method Name list select the event for which to write a procedure—events already having a written procedure appear in bold

6-29 Writing Event Procedures From the Properties Window in the Designer Select an event using the Properties window Click the form to show properties and click Events button Double-click the event to create an empty event procedure

6-30 Holding the Splash Screen Display If application are very small the splash screen disappears before it can be read Code can be written to hold the splash screen longer Private Sub SplashScreen_FormClosing(ByVal sender As Object, _ ByVal e As System.Windows.Forms.FormClosingEventArgs) _ Handles Me.FormClosing 'Hold the form on the screen approximately 5 seconds before closing System.Threading.Thread.Sleep(5000) 'Sleep 5000 milliseconds End Sub

6-31 Variables/Constants in Multiform Projects Scope of a variable or constant For single-form projects: The area of the program that can “see” and “use” the variable or constant For multi-form projects: The set of statements that can access a variable or constant without qualifying its name

6-32 Access Level Specifies the permission required to make use of the variable or constant Private keyword allows access only in the class (form) in which it is declared To make a variable available to other forms in a project, use either the Public or Friend keywords Friend - all other forms in the project can access it Public - all other programs can access it Only use access level keywords for module level variables; local and block-level variables are always private

6-33 Lifetime The period of time that a variable or constant remains in existence Module and namespace variables exist as long as the application runs Local and block-level variables exist only for the duration of the procedure that they are defined in

6-34 Static Variables Use to declare local and block level variables Retain their value for the life of the project If the value in a variable needs to be retained for multiple calls to a procedure such as running count, declare it as Static If the variable is used in multiple procedures, declare it at the module level

6-35 The Static Statement General Form Examples Static Identifier As DataType Static personCountInteger As Integer Statis reportTotalDecimal As Decimal

6-36 Namespaces VB projects are automatically assigned to a namespace Namespaces can be viewed and modified which is called the root namespace

6-37 Declaring Variables/Constants Guidelines Place all local declarations at the top of a procedure Use named constants for any value that doesn’t change during the program execution Keep the scope of variables and constants narrow Consider making variables local if possible Make variables Static if needed for multiple executions within a procedure If variables are needed for more than one procedure, declare it as local and pass it as an argument Use Private module level variables if using a variable in multiple procedures and displaying in another If using the value of a variable in more than one form declare it as Friend

6-38 Running a Program Outside the IDE The.exe file can be moved to another computer, placed on the system desktop, or used as a shortcut just like any other application If copying the.exe file to another system make sure it has the Microsoft.NET Framework Can download the framework for free from the Microsoft Web site Change the icon if desired