Visual Basic.NET Comprehensive Concepts and Techniques Chapter 6 Looping and Multiple Forms.

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
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Excel Web Feature Creating Static and Dynamic Web Pages Using Excel.
Microsoft Windows Vista Chapter 5 Personalize Your Work Environment.
COMPREHENSIVE Windows Tutorial 3 Personalizing Your Windows Environment.
Microsoft Office 2010 Access Chapter 1 Creating and Using a Database.
Macros Tutorial Week 20. Objectives By the end of this tutorial you should understand how to: Create macros Assign macros to events Associate macros with.
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)
Office XP Introductory Concepts and Techniques Windows XP Edition M i c r o s o f t Windows XP Project An Introduction to Windows XP Professional and Office.
Chapter 9 Macros, Navigation Forms, PivotTables, and PivotCharts
Microsoft Visual Basic 2008 CHAPTER ELEVEN Multiple Classes and Inheritance.
Microsoft Visual Basic 2012 CHAPTER TWO Program and Graphical User Interface Design.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
WORKING WITH MACROS CHAPTER 10 WORKING WITH MACROS.
Chapter 8: String Manipulation
CHAPTER SIX Loop Structures.
Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services.
CHAPTER 6 Loop Structures.
Microsoft Visual Basic 2012 CHAPTER TWELVE (ENRICHMENT CHAPTER) Windows Store Apps.
Chapter 3 Maintaining a Database
CHAPTER SIX.
Microsoft Office 2007 Access 2007 Chapter 9 Administering a Database System.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
Microsoft Visual Basic 2005 CHAPTER 9 Using Arrays and File Handling.
1 1 Lab1 Ismail M. Romi – IT Dept, PPU, Visual Basic 2005 Programming Tour.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 2 The Visual Basic.NET Integrated Development Environment.
Visual Basic 2005 CHAPTER 2 Program and Graphical User Interface Design.
Project 2 Adding Web Pages, Links, and Images Dreamweaver MX 2004 Concepts and Techniques.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 5 Decision Making.
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.
Windows Tutorial Common Objects ACOS: 1, 4. Using the Taskbar 1. Using the taskbar, you can switch between open programs and between open documents within.
 Application – another name for a program.  Interface – is what appears on the screen when the application is running.  Program Code – is instructions.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Program Design and Coding
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Microsoft Visual Basic 2010 CHAPTER THREE Program Design and Coding.
Dreamweaver CS4 Concepts and Techniques Chapter 2 Adding Web Pages, Links, and Images.
Visual Basic Programming Chapter Six Notes Repetition and the Do Statement ADDING ICONS TO YOUR FORM –It is possible to add an ______________ to your title.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Access Project 7 Advanced Report and Form Techniques.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 8 Debugging, Creating Executable Files, and Distributing a Windows Application.
Chapter 2 – Introduction to the Visual Studio .NET IDE
Project 2 Working on the Windows XP Desktop Windows XP Service Pack 2 Edition Comprehensive Concepts and Techniques.
Microsoft Visual Basic 2012 CHAPTER ELEVEN Multiple Classes and Inheritance.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 4 Working with Variables, Constants, Data Types, and Expressions.
Microsoft Office 2010 is the newest version of Microsoft Office, offering features that provide users with better functionality and easier ways to work.
Microsoft Visual Basic 2010 CHAPTER TWO Program and Graphical User Interface Design.
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Chapter 2 Introduction to Visual Basic Programming Visual Basic.NET.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 3 Building an Application in the Visual Basic.NET Environment.
Customizing Menus and Toolbars CHAPTER 12 Customizing Menus and Toolbars.
Visual Basic.NET BASICS Lesson 14 Menus and Printing.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 2 The Visual Basic.NET 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.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
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.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 6 Looping and Multiple Forms.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 12 Creating Console Applications, Understanding XML, and Creating Web Services.
Chapter 8 Multiple Forms, Modules, and Menus. Introduction This chapter demonstrates how to: – Add multiple forms to a project – Create a module to hold.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 11 Creating Web Applications and Writing Data to a Database.
Chapter 2 – Introduction to the Visual Studio .NET IDE
Program and Graphical User Interface Design
VISUAL BASIC FINAL EXAM REVIEW SHEET
Program and Graphical User Interface Design
Variables and Arithmetic Operations
Accessing Databases with ADO.NET, Handling Exceptions, and Printing
Looping and Multiple Forms TEST REVIEW
Presentation transcript:

Visual Basic.NET Comprehensive Concepts and Techniques Chapter 6 Looping and Multiple Forms

Chapter 6: Looping and Multiple Forms 2 Objectives Add additional forms to a project Change the default icon on the title bar of a form Use the ListView controls to display a list of items on a form Use the CheckBox controls in an application Use the Anchor property of controls

Chapter 6: Looping and Multiple Forms 3 Objectives Work with Collections in code Code a Do Until loop Code a Do While loop Code a For…Next and a For Each…Next loop Code a concatenation operator

Chapter 6: Looping and Multiple Forms 4 Objectives Code a keyboard event Code a form Resize event procedure Work with multiple code windows Specify a Startup object for a project

Chapter 6: Looping and Multiple Forms 5

6

7 Creating the User Interface Open a New Project named Today’s Sales Check in the Chapter6 folder on your Data Disk Set the following properties for your form

Chapter 6: Looping and Multiple Forms 8 Creating the User Interface Add a ListView control and three Button controls to your form Select the Icon property in the Properties window Click the Icon property ellipsis button. Select the CHECKMRK file from the C:\Program Files\Microsoft Visual Studio.NET\Common7\Graphics\Icons\Misc folder Click the Open button

Chapter 6: Looping and Multiple Forms 9

10

Chapter 6: Looping and Multiple Forms 11 Changing the Properties of a ListView Control Click the Columns property ellipsis button in the ListView Control Properties window Click the Add button Select the Text property value for the ColumnHeader1 member. Type Item Description as the property value. Select the Width property value for the ColumnHeader1 member. Type 190 as the property value and click the Add button

Chapter 6: Looping and Multiple Forms 12 Changing the Properties of a ListView Control Select the Text property value for the ColumnHeader2 member and type Total Sales as the property value. Select the Width property value for the ColumnHeader1 member and type 79 as the property value. Click the Add button. When the ColumnHeader3 member is added, select the Text property value for the ColumnHeader3 member. Type On Sale as the property value and click OK

Chapter 6: Looping and Multiple Forms 13 Anchoring Controls Select the three button controls on the form, by holding CTRL while clicking each button Click the button anchor indicator to select it. Click the left and top anchor indicators to deselect them and press ENTER Select lstTodaysSales and click the down arrow in the Anchor property of the Properties window Click the bottom and right anchors to select them, and press ENTER

Chapter 6: Looping and Multiple Forms 14 Changing the File Name of a Form Right-click the Form1.vb form in the Solution Explorer window Click the Rename command on the shortcut menu. Type Todays Sales Check Form.vb and press ENTER

Chapter 6: Looping and Multiple Forms 15 Adding a Form to a Project and Creating the Interface Right-click the Today’s Sales Check project in the Solution Explorer window and then point to Add on the shortcut menu Click the Add Windows Form command on the Add submenu and select Form1 in the Name text box and then type Add Item Form Click the Open button

Chapter 6: Looping and Multiple Forms 16 Creating an Interface on a Newly Added Form Add two Label controls, one TextBox control, one NumericUpDown control, a CheckBox control, and a button control Set the form, label, text box, and NumericUpDowncontrol properties as specified on pages VB 6.31 and VB 6.32

Chapter 6: Looping and Multiple Forms 17 CheckBox Control Properties

Chapter 6: Looping and Multiple Forms 18 Declaring an Object Using an Object Variable

Chapter 6: Looping and Multiple Forms 19 Declaring an Object and Showing a Form Enter the code below, beginning on line 119

Chapter 6: Looping and Multiple Forms 20 Looping and the Do Statement

Chapter 6: Looping and Multiple Forms 21 The Do While and Do Until Statements

Chapter 6: Looping and Multiple Forms 22 The While…End While Statement

Chapter 6: Looping and Multiple Forms 23 Implementing a Loop Using a Do Until Statement Enter the following code, starting on line 136

Chapter 6: Looping and Multiple Forms 24 Working with Collections in ListView Controls Group of one or more objects that can be accessed and operated on as a single entity

Chapter 6: Looping and Multiple Forms 25 Adding Items to a ListView Control Text Property SubItems Property

Chapter 6: Looping and Multiple Forms 26 Adding Items to a ListView Control Enter the following code, starting on line 137

Chapter 6: Looping and Multiple Forms 27 For…Next Statement Great for counter- controlled loops More efficient than a Do While Loop Easier to read Uses less memory Faster execution

Chapter 6: Looping and Multiple Forms 28 The Execution of a For…Next Loop The first time the loop executes, intNumber is initialized at 1 intNumber is compared with 100. Because it is less than or equal to 100, the statements in the For loop are executed Control returns to the For statement, where the value of intCount is incremented by 1

Chapter 6: Looping and Multiple Forms 29 The Execution of a For…Next Loop If the value of intCount is less than or equal to 100, execution of the For…Next loop continues When the value of intCount is greater than 100, control transfers to the statement following the corresponding Next statement

Chapter 6: Looping and Multiple Forms 30 Exiting a Loop Prematurely – The Exit Statement

Chapter 6: Looping and Multiple Forms 31 Nested For…Next Loops

Chapter 6: Looping and Multiple Forms 32 Implementing a Loop Using a For…Next Statement

Chapter 6: Looping and Multiple Forms 33 Implementing a Loop Using a For…Next Statement Enter the following code, starting on line 150

Chapter 6: Looping and Multiple Forms 34 The For Each…Next Statement

Chapter 6: Looping and Multiple Forms 35 Coding the String Replace() Method Click line 163 and enter the code below This code replaces the dollar sign in the strItemSales variable with a 0, so that the string can be converted to a number and used in an expression

Chapter 6: Looping and Multiple Forms 36 String Manipulation

Chapter 6: Looping and Multiple Forms 37 Concatenation Operators

Chapter 6: Looping and Multiple Forms 38 Coding a Concatenation Operator Enter the code below, starting on line 164

Chapter 6: Looping and Multiple Forms 39 Removing Items from a ListView Control Click the Todays Sales Form.vb[Design] tab in the main work area. Double-click the btnClearList button. When the code window appears, click line 181 and then enter the code below

Chapter 6: Looping and Multiple Forms 40 Keyboard Events Click the Object box arrow in the code window Click lstTodaysSales in the Object list. Click the Procedure box arrow in the code window. Select KeyDown in the Procedures list Enter the code below, starting on line 185

Chapter 6: Looping and Multiple Forms 41 Coding a Form Resize Event Click the Object box arrow in the code window Click Base Class Events in the Object list. Click the Procedures box arrow in the Procedures box in the code window. Select Resize in the Procedures list Enter the below lines of code, starting on line 191

Chapter 6: Looping and Multiple Forms 42 The Me Keyword and Coding a Second Form Click the Add Item Form.vb[Design] tab in the main work area. Double-click the btnOK button. Enter Option Strict On as the first line of code in the form Enter lines 120 through 127 of the code on the following slide Click the Add Item Form.vb[Design] tab in the main work area. Double-click any blank area on the form. Type lines 131 through 136 of code in the frmAddItem_Load event procedure

Chapter 6: Looping and Multiple Forms 43

Chapter 6: Looping and Multiple Forms 44 Setting the Startup Object for a Project Click the Today’s Sales Check project in the Solution Explorer window and then click the Property Page button in the Properties window Click the Startupobject box arrow. Select frmTodaySalesCheck in the list

Chapter 6: Looping and Multiple Forms 45 Click the OK button

Chapter 6: Looping and Multiple Forms 46 Finish the Project Click the Save All button on the Standard toolbar Test your project with the test data on page VB 6.79 Print your program’s documentation Quit Visual Basic.NET

Chapter 6: Looping and Multiple Forms 47 Summary Add additional forms to a project Change the default icon on the title bar of a form Use the ListView controls to display a list of items on a form Use the CheckBox controls in an application Use the Anchor property of controls

Chapter 6: Looping and Multiple Forms 48 Summary Work with Collections in code Code a Do Until loop Code a Do While loop Code a For…Next and a For Each…Next loop Code a concatenation operator

Chapter 6: Looping and Multiple Forms 49 Summary Code a keyboard event Code a form Resize event procedure Work with multiple code windows Specify a Startup object for a project

Visual Basic.NET Comprehensive Concepts and Techniques Chapter 6 Complete