Variables Data Types and Assignment

Slides:



Advertisements
Similar presentations
This is Java Jeopardy.
Advertisements

Driving Test 1 Marking Scheme Focus on five areas to pass driving test 1.
Week 2: Primitive Data Types 1.  Programming in Java  Everything goes inside a class  The main() method is the starting point for executing instructions.
Declaring Variables You must first declare a variable before you can use it! Declaring involves: – Establishing the variable’s spot in memory – Specifying.
Introduction to Python
Introduction to a Programming Environment
110-D1 Variables, Constants and Calculations(1) Chapter 3: we are familiar with VB IDE (building a form…) to make our applications more powerful, we need.
VARIABLES, TYPES, INPUT/OUTPUT, ASSIGNMENT OPERATION Shieu-Hong Lin MATH/CS Department Chapel.
CS0004: Introduction to Programming Variables – Numbers.
Week 2 - Monday.  What did we talk about last time?  Software development  Lab 1.
Rote Learning of the Week "A variable is a named section of RAM that stores data of a specific data type"
Variables "There are 10 kinds of people in the world today – those who understand binary and those who don't!” Unknown.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Logical or Boolean Data stored in Boolean form can only be one of two available values. Think of a light switch – it’s on or off. Examples include: YES.
3 - Variables Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
University of Sunderland CIF 102/FIF102 Fundamentals of DatabasesUnit 15 Programming in Microsoft Access using VBA Using VBA to add functionality.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 2: Introduction to C++
Data Types and Variables. Data Type! Computers are all about Data! Data can be in the form of Text Dates Sounds Pictures.
I Power Higher Computing Software Development Development Languages and Environments.
Sanjay Johal. Introduction(1.1) In this PowerPoint I will be explaining :  The purpose of the code for each of the two given programs, e.g. to carry.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
String and General Procedures. Answer to the last question of Exam 1 Start Get a number Divide the Number By 2 Is the quotient Equal to 1? Print The Remain.
Variables and Expressions CMSC 201. Today we start Python! Two ways to use python: You can write a program, as a series of instructions in a file, and.
# 1# 1 What is a variable that you create? What is a constant that you create? What is an intrinsic (built-in) constant? What variables are built in?
Programming with Microsoft Visual Basic th Edition
Variables 1. What is a variable? Something whose value can change over time This value can change more than once over the time period (no limit!) Example:
Program Organization Sequential Execution: One line done after the other Conditional Execution: If a test is true, one section is done, otherwise another.
Variables Hold information that may be manipulated, used to manipulate other information or remembered for later use A storage location in memory (RAM)
Variables Continued In the last session we saw how variables are objects that allow us to store values in the RAM of the computer In this session we shall.
Visual Basic CDA College Limassol Campus COM123 Visual Basic Programming Semester C Lecture:Pelekanou Olga Week 3: Using Variables.
Controlling Program Flow with Decision Structures.
DATA TYPES, VARIABLES AND CONSTANTS. LEARNING OBJECTIVES  Be able to identify and explain the difference between data and information  Be able to identify,
Data Handling in Algorithms. Activity 1 Starter Task: Quickly complete the sheet 5mins!
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are used in programs so that values can be represented with.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration statement. For example: Dim.
IMAT1604 Visual Web Development. About me… Matthew Dean (Or Google mjdean dmu)
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.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Bill Tucker Austin Community College COSC 1315
CMSC201 Computer Science I for Majors Lecture 03 – Variables
Unit 2 Technology Systems
Egyptian Language School Computer Department
Week 2 - Wednesday CS 121.
A variable is a name for a value stored in memory.
CMSC201 Computer Science I for Majors Lecture 02 – Intro to Python
Documentation Need to have documentation in all programs
Data Types, Arithmetic Operations
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
Variables and Primative Types
Variables Data Types and Assignment
Starter Question In your jotter write the pseudocode to take in two numbers, add them together then display the answer. Declare variables RECEIVE firstNumber.
Intro to PHP & Variables
Microsoft Visual Basic 2005 BASICS
2.1 Parts of a C++ Program.
Variables ICS2O.
Numbers.
Variables Numbers can be stored and retrieved while a program is running if they are given a home. The way that integers and decimal numbers are stored.
Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions GROUPBOX CONTROL The _____________________________________.
CS285 Introduction - Visual Basic
What is an Object Anyway?
ICT Programming Lesson 4:
Chapter 2: Introduction to C++.
Variables Data Types and Assignment
Primitive Types and Expressions
C# Revision Cards Data types
Subject:Object oriented programming
Variables and Constants
Presentation transcript:

Variables Data Types and Assignment

Stuff to memorise this Week "A variable is a named section of RAM that stores data of a specific data type"

Objects In the first lecture we introduced the idea of classes and objects One way of looking at an object is as the name we give to a class file so that we may access its methods and properties Once we have an instance of an object we may access the methods and properties defined in the class Property allows us to read or change the settings of an object Methods tell an object to perform an action   There are lots of different objects within the computer system all allowing us to control data in different ways

Screen Objects Event driven

System Architecture Presentation (Interface) Data Layer Database Middle Tier Business Logic (Objects/Classes)

Layers Split in to Other Layers Interface and code linked by events

Function for Click Event Handler Event Handler = Function that responds to an event

Interface v RAM Exercise Split into two teams Both teams to count from 1 – 50 One team to write the numbers on paper The other team to count in their heads Everybody stand Raise your hand when you have finished

The Assignment Operator The symbol for copying data around the system Possibly the most important concept in programming Fail to grasp how this works and you won’t progress

How it works txtMessage.Text = “Hello world”; The assignment operator copies data from right to left Destination = Source All together now!

Computer Technology We need objects & classes to control all this!

Where the RAM fits in The RAM

Variables and RAM Computer RAM is VERY COMPLICATED Stores data as binary values “hello” stored as … “0100100001000101010011000100110001001111” Variables spare us a great deal of pain! Variables are a very simple kind of object Allow us to control a section of RAM Three 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

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

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

Data Types Integer whole number Types of Int Int16 -32768 to +32787 Int32 (or just Int) -2,147,483684 to +2,147,483683 Int64 -9223372036854775808 to +9223372036854775807 String any combination of numbers and letters DateTime any valid date or time Boolean true or false Decimal any whole or decimal number

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

Think of Variables as Boxes in RAM The seven variables declared above have the following names… ErrMsg OfferTitle Description SwapNo Userno Email UserName A series of boxes are created…

Rules for Variable Names We do not have any spaces in the variable names Err Msg Bad ErrMsg Good Use underscore if you want a space e.g. Err_Msg The variable names use pascal or camel case swapno Bad SwapNo Good (public variable) swapNo Good (private variable) The names must be meaningful A, B & C are normally bad names as they give no clue as to their usage

Things we do with Variables Assign literal constants

Perform Calculations

Get data off the Interface string FirstName; FirstName = txtFirstName.Text;

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

Common Variable Errors We shall look at some common errors in Visual Studio Learn to recognise the errors Missing variable declaration Mismatched Variable Names Selection of incorrect data type Rounding errors Overflow errors