70 likes | 210 Views
2a – Object Oriented. CSCI N331 VB .NET Programming. Lingma Acheson. Department of Computer and Information Science, IUPUI. Object Oriented. Focus on Objects Objects in the real world Car iPod nano Button Label Picture …
E N D
2a – Object Oriented CSCI N331 VB .NET Programming Lingma Acheson Department of Computer and Information Science, IUPUI
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
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
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.
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? • …
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.
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.