Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #5

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
Lists, Loops, Validation, and More
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 5- 1 STARTING OUT WITH Visual Basic 2008 FOURTH EDITION Tony Gaddis.
CS0004: Introduction to Programming Select Case Statements and Selection Input.
VBA for MS Excel Hamze Msheik. Open the Visual Basic Editor in Excel 2007 Click on the Microsoft Office button in the top left of the Excel window and.
Chapter 7: Sub and Function Procedures
OOP-Creating Object-Oriented Programs
VB Classes ISYS 573. Object-Oriented Concepts Abstraction: –To create a model of an object, for the purpose of determining the characteristics (properties)
VBA Modules, Functions, Variables, and Constants
CSI 101 Elements of Computing Spring 2009 Lecture #10 – Functions and Subroutines Monday, March 16th.
User Defined Types, Collections, Enumerations & Classes CIS 338 Tony Lopez (a Cal Poly student) updated April 2003.
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.
VB Classes BICS546. Adding a Class to a Project Project/Add Class Class will be saved in a.CLS file Steps: –Adding properties Declare Public variables.
VB Classes ISYS 573. Object-Oriented Concepts Abstraction: –To create a model of an object, for the purpose of determining the characteristics (properties)
VB Classes ISYS 512. Adding a Class to a Project Project/Add Class –*** MyClass is a VB keyword. Steps: –Adding properties Declare Public variables in.
CSI 101 Elements of Computing Spring 2009 Lecture # 14 – Classes and Objects Wednesday, April 15th, 2009 and Monday, April 20th, 2009.
WORKING WITH FILES, MENUS AND DATABASES IN VISUAL BASIC BY V. V. SUBRAHMANYAM.
Chapter 8 Using Repetition with Loops and Lists. Class 8: Loops and Lists Write Do loops to execute statements repeatedly Write For loops to execute statements.
Tutorial 7: Sub and Function Procedures1 Tutorial 7 Sub and Function Procedures.
Tutorial 7: Sub and Function Procedures1 Tutorial 7 Sub and Function Procedures.
McGraw-Hill© 2007 The McGraw-Hill Companies, Inc. All rights reserved. 1-1.
Introduction to Object Oriented Design. Topics Designing Your Own Classes Attributes and Behaviors Class Diagrams.
CS0004: Introduction to Programming Variables – Numbers.
Module 7: Object-Oriented Programming in Visual Basic .NET
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
Ch 11: Userforms CP212 Winter Topics Designing User Forms o Controls Setting Properties o Tab Order o Testing Writing Event Handlers o Userform_Initialize.
Chapter 6 Understanding the Structure of an Application: Procedures, Modules, and Classes.
Why to Create a Procedure
Chapter 10: Writing Class Definitions Visual Basic.NET Programming: From Problem Analysis to Program Design.
CSCI 3327 Visual Basic Chapter 6: Methods: A Deeper Look UTPA – Fall 2011.
Chapter 9: Getting Comfortable with Object- Oriented Programming.
1 Visual Basic Checkboxes Objects and Classes Chapt. 16 in Deitel, Deitel and Nieto.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Fund Raiser Application Introducing Scope, Pass-by-Reference and Option Strict.
1 Classes and Controls CE-105 Spring 2007 By: Engr. Faisal ur Rehman.
SYSTEMSDESIGNANALYSIS 1 OO: Chapter 9 Visual Basic: Building Components Jerry Post Copyright © 1999.
1 Week 6 The Repetition Structure. 2 The Repetition Structure (Looping) Lesson A Objectives After completing this lesson, you will be able to:  Code.
Tutorial 6 The Repetition Structure
‘Tirgul’ # 3 Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #3.
CIS 338: Classes and Modules Dr. Ralph D. Westfall May, 2011.
Chapter 3: Creating ActiveX Controls By Noppadon Kamolvilassatian Dept. of Computer Engineering, Prince of Songkla University Source: Mastering Visual.
Applications Development
Chapter 6 OOP: Creating Object-Oriented Programs Programming In Visual Basic.NET.
CSCI 3327 Visual Basic Chapter 9: Object-Oriented Programming: Classes and Objects UTPA – Fall 2011.
‘Tirgul’ # 2 Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #2.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
VB Classes ISYS 512/812. Object-Oriented Concepts Abstraction: –To create a model of an object, for the purpose of determining the characteristics (properties)
COMPUTER PROGRAMMING 2 ArrayLists. Objective/Essential Standard Essential Standard 3.00Apply Advanced Properties of Arrays Essential Indicator 3.02 Apply.
Visual Basic Review LBS 126. VB programming Project Form 1Form 2Form 3 Text boxButton Picture box Objects Text box Button Objects.
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.
Chapter 13 Copyright 2000 All rights reserved 1 Chapter 13 Object-Oriented Programming.
Creating New Forms Projects can appear more professional when using different windows for different types of information. Select Add Windows Form from.
Object-Oriented Programming: Classes and Objects Chapter 1 1.
Chapter 9 Introduction to Arrays Fundamentals of Java.
‘Tirgul’ # 5 Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #5.
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
Visual Basic I Programming
Multiple Forms and Menus
VBA - Excel VBA is Visual Basic for Applications
IS 350 Application Structure
Object-Oriented Programming: Classes and Objects
Anatomy of a Class & Method
Object-Oriented Programming: Classes and Objects
Tutorial 19 - Microwave Oven Application Building Your Own Classes and Objects Outline Test-Driving the Microwave Oven Application Designing.
Object-Oriented Programming
CSCI 3327 Visual Basic Chapter 6: Methods: A Deeper Look
CIS16 Application Development and Programming using Visual Basic.net
CIS 199 Final Review.
Just Basic Lessons Mr. Kalmes.
Presentation transcript:

Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #5

Objectives Understanding objects Class Modules Properties Get/Let Defining Types Collections ‘Tirgul’ # 5

Object Classes Objects contains: Data Behavior Controls are objects data (properties) behavior(Functions and events) All objects of the same type has the same data and behavior ‘Tirgul’ # 5

The Class Module A class is a template: it defines the data and behavior of the objects that belong to it. An instance is a variable associated with an object (a specific instance of a class). ‘Tirgul’ # 5

timeToCrewel(Dist as integer) as integer setSpeed(Speed as integer) The Snail Abstraction timeToCrewel(Dist as integer) as integer age goToSleep() IsSleep setSpeed(Speed as integer) Color Gender Properties Functions ‘Tirgul’ # 5

All Objects has the same properties and behavior Multiple instances of a class Class Car Color as Colur Speed as Double Size as Double Color = red Speed = 200 Size = 100.5 Color = Blue Speed = 120 Size = 160.7 Color = Yellow Speed = 90 Size = 150.6 All Objects has the same properties and behavior But not same values ‘Tirgul’ # 5

Property Methods Provide access to the instance variables can assign or retrieve the value of an instance variable property A named attribute of an object. Define object characteristics such as size, color, and screen location, or the state of an object, such as enabled or disabled. ‘Tirgul’ # 5

Property Let Assign a value to a class property Syntax: Optionally: Use ByVal retain the value of the parameter Dim sName as String Property Let Name(ByVal newName As String) sName = newName End Property ‘Tirgul’ # 5

Property Get Gets a value of a property Syntax: Dim sName as String Property Get Name() as String Name = sName End Property ‘Tirgul’ # 5

Class Initialization Important for defaults Will be called each new Instance Private Sub Class_Initialize() CTN = “050000000” age = 0 fName = “” End Sub ‘Tirgul’ # 5

Behavior Functions Defines the behavior of the object Done same as form functions/Subs Public will be used by the user Private will be hidden for the user Public function getSalary(code as integer) as double getSalary = getSalaryByCode(code) End function Private function getSalaryByCode(code as integer) as double getSalaryByCode = rsSalary.Field(code).value ‘Tirgul’ # 5

Class can use class ‘Tirgul’ # 5

Declaring an Object Variable You need to define the object and create new instance. Could be done in the same line but better to separate Set: Assign an object reference to variable Dim myStudent as new cStudents Dim myStudent as cStudents … Set myStudent = new cStudents ‘Tirgul’ # 5

Collections A very useful object to hold objects Unlike List, can hold Objects Functions Add – Adding objects Item(index) – retrieve the Item in the index Count – Number of items Remove(Index) – remove an Item in the index Dim Emp1 as new cEmployee Dim Emp2 as new cEmployee Dim Factory As New Collection Factory.Add Emp1 Factory.Add Emp2 ‘Tirgul’ # 5

Item Method Retrieves a specific Item from the collection For index = 1 To Factory.Count Debug.Print Factory.Item(index).Name Next index Property of the item ‘Tirgul’ # 5

Programmer defined Data Types Type is a degenerate class In a form (private) or module(Public) Useful to hold data in a logic group Referenced as a base type (no New) Public Type Point x as Integer Y as Integer End Type Dim myPoint as Point myPoint.x = 1 myPoint.y = 2 4 3 2 1 1 2 3 4 ‘Tirgul’ # 5

Source Examples prjEmployee – Simple class use prgStudent – Properties use prgRoll_Call - Class_Initialize, Container class prgOrderItem – with reserved word prgBankAccount – Class functions prgArithmeticSeries Lec3LinkList – List example ‘Tirgul’ # 5