‘Tirgul’ # 5 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
Chapter 5 Menus, Common Dialog Boxes, Sub Procedures, and Function Procedures Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved.
OOP-Creating Object-Oriented Programs
OOP: Creating Object-Oriented Programs. VB & Object Oriented Programming Objects have properties, methods, and generate events Classes have been predefined.
Java Programming, 3e Concepts and Techniques Chapter 5 Arrays, Loops, and Layout Managers Using External Classes.
VBA Modules, Functions, Variables, and Constants
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.
1 Prototyping for HCI Spring 2004 (Week 8) Jorge A. Toro.
VB Classes ISYS 573. Object-Oriented Concepts Abstraction: –To create a model of an object, for the purpose of determining the characteristics (properties)
VB Code Statements 3 types of VB statement The Remark statement, known as comments, are used for project documentation only Begin with an apostrophe Not.
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.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
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.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
Copyright © 2001 by Wiley. All rights reserved. Chapter 12: Programmer- Defined Types, Direct Access Files, and Object Classes Programmer Defined Data.
Chapter 6 Understanding the Structure of an Application: Procedures, Modules, and Classes.
Why to Create a Procedure
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.
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.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
Chapter 9 - VB.Net by Schneider1 Chapter 9 – Additional Controls and Objects 9.1 List Boxes, Combo Boxes, and the File-Opening Control The List Box Control.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
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
Overview of VBA Programming & Syntax. Programming With Objects u Objects –Properties: attributes or characteristics of an object (e.g., font size, color,
‘Tirgul’ # 2 Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #2.
VB Classes ISYS 512/812. Object-Oriented Concepts Abstraction: –To create a model of an object, for the purpose of determining the characteristics (properties)
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
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.
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.
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
Visual Basic I Programming
Multiple Forms and Menus
Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #5
IE 8580 Module 4: DIY Monte Carlo Simulation
VBA - Excel VBA is Visual Basic for Applications
IS 350 Application Structure
Chapter 1: An Introduction to Visual Basic 2015
Object-Oriented Programming: Classes and Objects
Using Procedures and Exception Handling
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.
CS285 Introduction - Visual Basic
Tonga Institute of Higher Education
CIS16 Application Development and Programming using Visual Basic.net
Chapter 8 - Functions and Functionality
Introduction to VB programming
Presentation transcript:

‘Tirgul’ # 5 Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #5

‘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 The Snail Abstraction age Color Gender timeToCrewel(Dist as integer) as integer IsSleep Properties Functions setSpeed(Speed as integer) goToSleep()

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

‘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 Gets a value of a property Syntax: Property Get Dim sName as String Property Get Name() as String Name = sName End Property

‘Tirgul’ # 5 Property Set Sets a value to an Object Syntax: Use Dim mvartest as Variant Public Property Set test(ByVal vData As Variant) Set mvartest = vData End Property Set x.test = Form1

‘Tirgul’ # 5 Class Initialization Important for defaults Will be called automatically at each new Instance Private Sub Class_Initialize() CTN = “ ” 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 End function

‘Tirgul’ # 5 Class can use class

‘Tirgul’ # 5 Declaring an Object Variable Dim myStudent as cStudents … Set myStudent = new cStudents 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

‘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 Retrieves a specific Item from the collection Item Method 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 =

‘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 Class Builder click Project Add Class module and select VB Class Builder:

‘Tirgul’ # 5 Add Method select File, New, Method. Enter Method name, click OK. You should now see the Method in the right hand pane Update the project click File, Exit.

‘Tirgul’ # 5 Add Method