Presentation is loading. Please wait.

Presentation is loading. Please wait.

Objects Allow us to represent and control the computer technology Use methods to make the object do something Use properties to find out and change the.

Similar presentations


Presentation on theme: "Objects Allow us to represent and control the computer technology Use methods to make the object do something Use properties to find out and change the."— Presentation transcript:

1

2 Objects Allow us to represent and control the computer technology Use methods to make the object do something Use properties to find out and change the settings of the object

3 Screen Objects

4 The Assignment Operator The symbol for copying and allocating data around the system Very important concept in programming

5 How it works txtMessage.Text = “Hello world” ‘The message hello world is assigned to the text box named message The assignment operator copies data from right to left Left Right Destination = Source

6 Variables and RAM Computer RAM is VERY COMPLICATED It stores data as binary values “hello” stored as … “0100100001000101010011000100110001001111” Variables spare us a great deal of pain!

7 Variables cont’d Variables are a very simple kind of object They allow us to control a section of RAM Four things we want to do… Allocate a section of RAM Give that section a name Set the rules for the type of data it will store Store some data in the variable

8 Think as Variables a Boxes in RAM or of all the information we want to store The seven variables declared above have the following names… ErrMsg OfferTitle Description SwapNo Userno Email UserName A series of boxes are created…

9 Data Types Notice also in declaring variables we give them a data type, e.g. As String Sets the rule as to the type of data we may put in the box

10 Creating Variables Variables are “declared” using the key word “Dim”

11 Declare Variables at the top of your code… Makes them easier to find Must declare a variable before we may use it

12 Global and Local Variables Local : For use for a particular object only i.e. btnCalculate Set variable inside the Private sub Global: For use for the whole programme i.e. Mini Calculator Set variable at the start of programme underneath Public class

13 Rules for Variable Names We do not have any spaces in the variable names Err MsgBad ErrMsgGood Use underscore if you want a space e.g. Err_Msg The variable names use pascal case swapnoBad SwapNo Good The names must be meaningful A, B & C are normally bad names as they give no clue as to their usage

14 Data Types Integer whole number in the range from - 2,147,483,648 to 2,147,483,647 Byte whole number between 0 and 255 String any combination of numbers and letters Dateany valid date or time Booleantrue or false Decimalany whole or decimal number big range so good for mathematical calculations

15 Processing data (Input) Dim FirstName as String FirstName = txtFirstName.Text This would enable us to input a first name (letters/text) in to a text box named FirstName. It would not allow numbers or any other data type.

16 A Simple Application To finish off we will create the following application…

17 With the following code…

18 Common Variable Errors Learn to recognise the errors Missing variable declaration Mismatched Variable Names Selection of incorrect data type


Download ppt "Objects Allow us to represent and control the computer technology Use methods to make the object do something Use properties to find out and change the."

Similar presentations


Ads by Google