2a – object oriented lingma acheson department of computer and information science, iupui csci...

7
2a – Object Oriented Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB .NET Programming

Upload: della-ford

Post on 18-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 2a – Object Oriented Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming

2a – Object Oriented

Lingma AchesonDepartment of Computer and Information Science, IUPUI

CSCI N331 VB .NET Programming

Page 2: 2a – Object Oriented Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming

Object Oriented• Focus on Objects• Objects in the real world

– Car– iPod nano– Button– Label– Picture– …

• Must give the details of an object to let people know about that particular object

Page 3: 2a – Object Oriented Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming

Objects• Can do something to the object

– Car: drive, wash, reverse, park, …– iPod nano: play songs, delete songs, charge, …– Picture: display, frame, copy, …

• Defining an object means designing a blue print for the object, e.g. what properties should it have, what can it do?

• Can manufacture lots of objects from the same blue print, but with different properties

Page 4: 2a – Object Oriented Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming

Objects in VB .NET• Any language inside Visual Studio are

object oriented. E.g. VB.NET objects: Labels, Textboxes, Buttons, Forms, Checkboxes…

• Download, unzip and open the “Inventory” project.

• Double clicking on the Form frame or clicking on the “View Code” icon in Solution Explorer will bring up the code window.

Page 5: 2a – Object Oriented Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming

Define an Object• An object in VB .NET is defined by

creating a “Class” (the blue print)• The objects in the Toolbox are already

defined in Visual Studio, thus are ready to use. E.g. Textbox properties:– What is the name of the textbox?– What is the text shown in the textbox?– What is the size of the textbox?– What is the background color?– What is the font and color of the text inside the

box?– …

Page 6: 2a – Object Oriented Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming

Create an Object Instance

• Creating a new object means creating an instance of a particular Class (type). E.g. Creating three textboxes means creating three textbox objects of the Class “Textbox”.

• Once we create an object, we can manipulate the properties of the object and decide on the behavior of the object.

• E.g. the behavior of a button – once the user click on the button, it will calculate the total and display in the Total textbox.- a “button click” event.

Page 7: 2a – Object Oriented Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming

Summary• An object in VB .NET shares the same

concept as a real world object.• A Class means a blue print of the

object.• Creating an object means creating an

instance based on the blue print.• Once an object is created, we can

change the properties of the object.• We can also define the events.