Objects, Instructions and Passing Data

18

description

Objects, Instructions and Passing Data. What is Programming?. Computer programming is about telling the computer what it is we want it to do We tell the computer what we want it to do by sending instructions to objects or passing data to / between Objects. Computer Components. - PowerPoint PPT Presentation

Transcript of Objects, Instructions and Passing Data

Page 1: Objects, Instructions and Passing  Data
Page 2: Objects, Instructions and Passing  Data

What is Programming?Computer programming is about telling the

computer what it is we want it to do

We tell the computer what we want it to do by sending instructions to objects or passing

data to / between Objects

Page 3: Objects, Instructions and Passing  Data

Computer ComponentsA computer is made up of many different bits of hardware

and computer technology. For example The Screen

The KeyboardThe MouseMemoryHard disc drivesDatabasesE Mail SystemsSound Cards

Page 4: Objects, Instructions and Passing  Data

Why use Objects?Dealing directly with hardware can be very

complicated

We create things called objects which allow us to control the hardware without worrying about how the hardware works

An object is a way of representing computer technology in such a way so that we send it instructions and data

Page 5: Objects, Instructions and Passing  Data

Types of ObjectWeb Forms and Controls

Used to create the interface on – screen

.NET Library ObjectsReady made objects allowing us to do things such a print

or send emails.

VariablesThese objects allow us to store data in the memory of

the computer

Custom ObjectsYou may create your own Objects to perform a whole

host of tasks

Page 6: Objects, Instructions and Passing  Data

Send Password

We shall look at the code for “Send me my password” to see how objects may be used to control the hardware.

Page 7: Objects, Instructions and Passing  Data

Consider the Hardware Involved!The userTypes their first name the keyboard & screenTypes their second name the keyboard & screenEnters their email address the keyboard &

screenPresses the send password button the mouse &

screen The systemSends an email to the user email message

& server

Page 8: Objects, Instructions and Passing  Data

The Click Event

In design view double click the button to view the code for the click event

Page 9: Objects, Instructions and Passing  Data

Add a Break Point

A break point forces the program to stop and wait so that we may see what is happening. To do this press F9. Now try and set up a new user.

Page 10: Objects, Instructions and Passing  Data

Things to NoteHandles btnPassword.ClickSub – End SubComments

Block commentsIn-Line comments

Page 11: Objects, Instructions and Passing  Data

Stepping Through the Code

The program will stop at your breakpoint and wait for further instructions. Press F10 to see how the code executes.

Page 12: Objects, Instructions and Passing  Data

Assignment StatementNotice how the following section of code

works…

In this case a text box object sends data to a variable (object)

Page 13: Objects, Instructions and Passing  Data

Sending an EMailPress F10 a few more times to see how the email is

sent using the email and smtp server objects…

Page 14: Objects, Instructions and Passing  Data

Overview of Objects Covered so farControl objects e.g. txtFirstName

Used to control the interface

 Variable objects e.g. FirstName

Used to control the RAM .NET Library objects e.g. MyEMail

Used to create an e mail message

Page 15: Objects, Instructions and Passing  Data

Properties and MethodsPropertiesA property is used to control some setting of the object or

to find out something about the object.e.g. txtFirstName.text

MethodsA method is a command to an object to do somethingThe following lines of code contain a method…

Page 16: Objects, Instructions and Passing  Data

SummaryComputer programming is about telling the computer what

it is we want it to do.

The problem with this computer technology is that there is a huge amount of complexity involved in directly programming them.

  In order to get around this we use as programmers tools

called objects. An object is a way of representing computer

technology in such a way so that we send it instructions and data

Page 17: Objects, Instructions and Passing  Data

QuestionsObjects can in theory be used to control any kind of

technology. In these questions imagine that we had objects to control a toaster or a light bulb.

1. Write in your own words a definition of the word “object”.

 2. In the case of an object, a method is a task that

does something; a property tells us something about the state of the object. If we were to create an object to control a toaster via VB.NET what methods and properties might it have?

Page 18: Objects, Instructions and Passing  Data

Questions 3. If a toaster object has a property called

“PowerOn”, write a line of code that might turn the power on.

 4. What is the = sign called that is used to transfer

data around the program? 5. In the case of a light bulb object, what is wrong

with the following line of VB.NET code? True = MyLightBulb.On