Multiple Forms and Menus

Slides:



Advertisements
Similar presentations
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Excel Project 7 Using Macros and Visual Basic for Applications (VBA) with Excel.
Advertisements

Using Macros and Visual Basic for Applications (VBA) with Excel
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.
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.
Chapter 5 - Menus, Sub Procedures, and Sub Functions  Menus - controls - properties and events –menu editor - create and change –defining menus - menu.
Using the Visual Basic Editor Visual Basic for Applications 1.
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
Copyright © 2014 Pearson Education, Inc. Chapter 7 Multiple Forms, Modules, and Menus.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Word Project 8 Working with Macros and Visual Basic for Applications (VBA)
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
McGraw-Hill/Irwin Programming in Visual Basic 6.0 © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Update Edition Chapter 6 Multiple Forms.
Multiple Forms, Standard Modules, And Menus
® Microsoft Access 2010 Tutorial 11 Using and Writing Visual Basic for Applications Code.
5-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
McGraw-Hill © 2009 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 5 Menus, Common Dialog Boxes, Sub Procedures, and Function Procedures.
Chapter 5 Menus, Common Dialog Boxes, and Methods Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Chapter 1 Creating a Dreamweaver Web Page and Local Site
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
Microsoft Access 2010 Chapter 8 Advanced Form Techniques.
Visual Basic.NET BASICS Lesson 1 A First Look at Microsoft Visual Basic.NET.
Chapter 2 – Introduction to the Visual Studio .NET IDE
Slide 1 Using Menu Bar & Common Dialog Boxes. Slide 2 Setting Up the Main Items v First open the form on which you want the menu located v Then start.
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.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
COMPREHENSIVE Access Tutorial 11 Using and Writing Visual Basic for Applications Code.
Creating New Forms Projects can appear more professional when using different windows for different types of information. Select Add Windows Form from.
Customizing Menus and Toolbars CHAPTER 12 Customizing Menus and Toolbars.
Visual Basic.NET BASICS Lesson 14 Menus and Printing.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
 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.
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
Chapter 8 Using Document Collaboration, Integration, and Charting Tools Microsoft Word 2013.
Dive Into® Visual Basic 2010 Express
Chapter 3: I Need a Tour Guide (Introduction to Visual Basic 2012)
Shelly Cashman: Microsoft Word 2016
Visual Basic.NET Windows Programming
Getting Started with Application Software
Apply Procedures to Develop Menus, List Box and Combo Box Objects
Chapter 1: An Introduction to Visual Basic 2015
Chapter 2 – Introduction to the Visual Studio .NET IDE
3.01 Apply Controls Associated With Visual Studio Form
1. Introduction to Visual Basic
3.01 Apply Controls Associated With Visual Studio Form
Microsoft Access Illustrated
Using Procedures and Exception Handling
Apply Procedures to Develop Menus, List Box and Combo Box Objects
Objectives Learn about Function procedures (functions), Sub procedures (subroutines), and modules Review and modify an existing subroutine in an event.
Chapter 7 Advanced Form Techniques
Variables and Arithmetic Operations
VISUAL BASIC.
Chapter 6 Multiform Projects
Chapter 2 – Introduction to the Visual Studio .NET IDE
Multiple Forms, Modules, and Menus
Chapter 2 Creating a Research Paper with References and Sources
Key Applications Module Lesson 12 — Word Essentials
Visual Basic Menu Editor
Introduction to Programming
Key Applications Module Lesson 12 — Word Essentials
Chapter 8 Using Document Collaboration and Integration Tools
Chapter 4 Enhancing the Graphical User Interface
Tutorial 11 Using and Writing Visual Basic for Applications Code
Lab 07 Creating Documents with Efficiency and Consistency
Presentation transcript:

Multiple Forms and Menus Creating new forms - under Project select Add form Removing a form - under Project select Remove form Hide and Show Methods When running one form you may wish to display another form. - call a new form - put Show method in the code for the original form - return to the original form - put the Hide method in the code for the Exit button on the new form.

Example P. 163, 187 Private Sub mnuFileNewCustomer_Click() ‘Display the billing form frmSummary.Show End Sub Example P. 164, 189 Private Sub cmdOK_Click( ) ‘Hide the summary form frmSummary.Hide Referring to objects on a different form - general syntax is FormName!VariableName Example P. 164 frmSummary!lblTotalAmount.Caption = mcTotal Example P. 187 Private Sub cmdComplete_Click ( ) frmMain!lblCupCount.Caption = piCupCount

Standard Code Modules A standard code module is a piece of code which is used by several forms. - create a standard code module - under Project select Add Module - type in the code. - save the code (This creates a file with the extension .BAS) Variables and constants in multiple forms projects Definition A global variable is a variable which is defined in the whole project (on every form). A module level variable is a variable which is defined in every procedure or function on one form. A local variable is a variable which is defined in one procedure or function.

Note The scope of a global variable is all the code in the entire project. The scope of a module-level variable is the code associated with one form. The scope of a local variable is the procedure in which it is defined, along with any procedure to which it is passed. Global variables and constants In the variable declaration, replace Dim by Public. Also, use a prefix of p to indicate that the variable or constant is Public. Example P. 166 Public pcGrandTotal As Currency Public Const psTAX_RATE = .2 As Single

Static variables Definition A static variable is a local variable which retains its value between procedure and function calls. Example P. 167 Static iPersonal As Integer Guidelines for variables and constants P. 168 Keep the scope of each variable as narrow as possible. (a) When you have a choice, make variables and constants local. (b) If a variable is used in several procedures on one form, make the variable module-level. (c) If a variable is changed on more than one form, make it Public. If a variable is referred to on more than one form but computed on only one form, make it module level. (d) Put Public variables in a standard code module.

An “About” Box - a form containing some information and (usually) an “OK” button Example P. 169 Menus The Menu Editor is a dialogue box which allows you to create menus. (P. 170 Fig. 6.6) There are two ways to call the menu editor. Method 1 Under Tools select Menu Editor. Method 2 Right-click on the form and select Menu Editor. The Menu Editor The Caption box lets you create the caption on the form. The Name box lets you name the menu item for the code. - names are preceded by mnu, the name of the menu, and the name of the item

Example Captions Names &File mnuExit &Exit mnuFileExit Creating a list - create the first menu item - create the second menu item and hit the right arrow key Example To create File Exit (1) type Caption File Name mnuFile (2) type Caption Exit Name mnuFileExit Hit the right arrow key.

Separator bar This is a line in a menu which divides items into separate categories. (You can see this in each of the Visual Basic menus.) - in Caption type - (the hyphen symbol) - in Name type any name List box This is the box at the bottom which displays the items which you have created. Submenus - create a menu item - hit the right arrow twice Checked and enabled

Creating a menu P. 172 - 174 Step 1. Display the Menu Editor Step 2. Type Caption and Name for the first menu. Step 3. Click on Next. Step 4. Click on the right arrow key (to indent). Step 5. Type in the menu items. For a submenu, click the right arrow key twice. Modify the menu - use the Menu Editor Code for the menu items - as for any other control Toggling check marks on and off - in code, use an If statement Example P. 175

Standards for Windows menus - include keyboard access commands - organize menus as Windows and Macintosh do Common dialog boxes - place the Common Dialog icon into the toolbox - under Properties select Components - select the dialog box option - from the toolbox, place a common dialog box onto the form One common dialog box allows you to display any of the dialog boxes in Visual Basic. Syntax - general object.ShowMethod - Example dlgCommon.ShowColor ‘Display color palette

Using information from the Color dialog box Example P. 178 In the code dlgCommon.ShowColor The Color dialog box appears, and the user selects a color. frmMain.BackColor - dlgCommon.Color Example P. 178 Using the Font dialog box Setting current values Do this before using a dialog box.

Programming Hints Setting the startup form - under Project select Properties - select the General tab - go to Select startup and highlight the desired form Adding an existing form - under Project select Add form Maximizing the window - in the Properties window set Windowsize to Maximize