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
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide STARTING OUT WITH Visual Basic 2008 FOURTH EDITION Tony Gaddis.
Advertisements

Classes, Exceptions, Collections, and Scrollable Controls
Introduction to Visual Basic.NET Uploaded By: M.Sheraz anjum.
Chapter 12 OOP: Creating Object- Oriented Programs Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
Object Oriented Programming Intermediate VB Doug Waterman Fox Valley Technical College.
Chapter 10 Database Applications Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
The Web Warrior Guide to Web Design Technologies
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.
12-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Chapter 6 Multiform Projects Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
OOP-Creating Object-Oriented Programs
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 Chapter 12 More OOP, Interfaces, and Inner Classes.
OOP: Creating Object-Oriented Programs. VB & Object Oriented Programming Objects have properties, methods, and generate events Classes have been predefined.
VBA Modules, Functions, Variables, and Constants
instance variables property procedures for the mintQuantity instance variable.
Creating Object Oriented Programs Object oriented (OO) terminology Class vs. object Instantiate an object in a project Understand Class_Initialize / Terminate.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Introduction to Class Modules Please use speaker notes for additional information!
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Object Based Programming. Summary Slide  Instantiating An Object  Encapsulation  Inheritance  Polymorphism –Overriding Methods –Overloading vs. Overriding.
Microsoft Visual Basic 2005: Reloaded Second Edition
An Object-Oriented Approach to Programming Logic and Design
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.
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
Microsoft Visual Basic 2005 CHAPTER 9 Using Arrays and File Handling.
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Multiple Forms and Standard Modules
Using Arrays and File Handling
Chapter 8: Writing Graphical User Interfaces
8-1 Chapter 8 Using User-Defined Data Types and Object Oriented Programming.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. ACCESS 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 6 – Designing.
Programming Examples to Accompany Structure Topic Please use speaker notes for additional information!
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
Lecture Set 11 Creating and Using Classes Part B – Class Features – Constructors, Methods, Fields, Properties, Shared Data.
Chapter 6 OOP: Creating Object-Oriented Programs Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
SYSTEMSDESIGNANALYSIS 1 OO: Chapter 9 Visual Basic: Building Components Jerry Post Copyright © 1999.
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.
Advanced Object- Oriented Programming Programming Right from the Start with Visual Basic.NET 1/e 14.
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.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Chapter 6 OOP: Creating Object-Oriented Programs Programming In Visual Basic.NET.
Vocabulary in VB So Far. Assignment: Used to change the value of an object at run time Used to change the value of an object at run time.
1.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
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.
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
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.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Chapter 2 Introduction to Visual Basic Programming Visual Basic.NET.
CHAPTER THREE Representing Data: Constants and Variables.
Chapter 13 Copyright 2000 All rights reserved 1 Chapter 13 Object-Oriented Programming.
Object-Oriented Programming: Inheritance and Polymorphism.
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.
Object-Orientated Programming
CIS16 Application Development Programming with Visual Basic
Object-Oriented Programming
Object-Oriented Programming: Inheritance and Polymorphism
Please use speaker notes for additional information!
CIS16 Application Development and Programming using Visual Basic.net
To understand what arrays are and how to use them
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 Ch. 9: Creating Object Oriented Programs  Object oriented (OO) terminology  Class vs. object  Instantiate an object in a project  Understand Class_Initialize / Terminate events  Create an object collection  Use Object Browser  Add properties to a form

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill VB & Object Oriented Programming  Objects have properties, methods, and generate events  Classes have been predefined up until now –Text box class –Form or command button class  VB supports writing object oriented (OO) programs

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill VB & Object Oriented Programming  Big advantage of OOP is the ability to reuse objects.  Reusing objects saves time and effort  You can create three objects from the same class, yet you can set their properties differently.

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Classes  Design new behaviors and properties for classes you create  You assign property values in your class  You assign properties or reveal them with Property Get and Property Let procedures

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Creating a New Class 1) Define a new class module 2) Define the class properties 3) Add property procedures 4) Create a method 5) Save the class module

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Defining Class Properties  Declare properties of a class with variables (called instance variables)  Variables are private and placed in General Declaractions section  Add property Let and Get procedures for each instance variable  Code a method, which is a class’ behavior

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Creating a New Object Using a Class  Creating a class module defines a new class  Code that creates and uses objects is placed in form and code modules, whereas a class must be placed in a class module  Create an object of a class with the New keyword—called instantiating an object  The New keyword creates a new instance of a class when the object is first used

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Choosing When to Create New Objects  The Set statement is another way to instantiate an object  Program has more control over when object is created with the Set statement  Form: Private As Set = New  Set statement is assignment statement for object variables

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Initialize and Terminate Events  VB uses class two special procedures for class definitions: –Class_Initialize –Class_Terminate  Class_Initialize method is invoked each time an instance of a class is created  Class_Terminate method is invoked each time an instance of a class is destroyed

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Terminating Projects  When a project terminates, use the Unload statement to unload all forms before executing the End statement  Unloading forms gives VB a chance to release resources and invoke the Class_Terminate event  Unload all forms using a For Each loop (see notes)

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Collections  VB provides a collection, which stores a group of individual objects  Collection can be treated as a single unit  A collection class contains references of all objects created of the same class  Collection has: Add method, Remove method, Item method, and Count property  Use plural of object to name class: Forms is collection of any form created in project

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Using a Collection in a Form

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Using the Object Browser  Object Browser reveals names of objects, properties, methods, events, and VB constants  View objects: View, Object Browser  Object Browser is best way to look up an object’s available properties, methods, etc.  Select an object and press F1 for help

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Using a List Box to Store the Keys  Reference collection members with unique keys  Keeping track of keys is difficult  Keys can be stored in a list box & kept in sorted order  List’s ItemData property holds the collection key

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill List Box can Display an Object  User selects a name from the list box  Your code uses the ItemData property to reference the correct member of the collection  You populate form text boxes with the selected member’s fields

Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Hands-On Programming Example  Hands on project manages employees with two forms: –Main form –Employee data form  Main form is used to select employee  Employee data form displays employee data