Variables Hold information that may be manipulated, used to manipulate other information or remembered for later use A storage location in memory (RAM)

Slides:



Advertisements
Similar presentations
Working with Intrinsic Controls and ActiveX Controls
Advertisements

Tutorial 31 Variable Memory location whose value can change as the program is running. Used to hold temporary information Used to control the type of data.
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Lecture Set 4 Data Types and Variables Part B – Variables, Constants, Expressions Conversion Rules Options Strict, Option Explicit Scope of Definition.
VARIABLES: Your Own Piece of the ram. Why Use Variables? To save a piece of data in memory To save a piece of data in memory To store results of a calculation.
Chapter 3: Introducing the Microsoft.NET Framework and Visual Basic.NET Visual Basic.NET Programming: From Problem Analysis to Program Design.
CIS 115 Lecture 5.  A storage location in memory (RAM)  Holds data/information while the program is running  These storage locations can be referred.
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 and Constants
CS0004: Introduction to Programming Variables – Numbers.
© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 2: Chapter 3: Slide 1 Unit 2 Variables and Calculations Chapter 3 Input,
Mr C Johnston ICT Teacher BTEC IT Unit 06 - Lesson 05 Learning To Program.
2440: 211 Interactive Web Programming Expressions & Operators.
Chapter 3 Part 11 Variables, Constants, and Calculations Chapter 3 Section 3.3 Chapter 3 Section 3.4.
Lecture 8 Visual Basic (2).
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Chapter 2: Using Data.
3 - Variables Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Data Types and Variables. Data Type! Computers are all about Data! Data can be in the form of Text Dates Sounds Pictures.
Items in Visual Basic programs
PHY-102 SAPVariables and OperatorsSlide 1 Variables and Operators In this section we will learn how about variables in Java and basic operations one can.
Primitive Variables.
Variables & Function Calls. Overview u Variables  Programmer Defined & Intrinsic  Data Types  Calculation issues u Using Functions  The val() function.
Variable, Constants and Calculations Dr Mohammad Nabil Almunawar.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
Introduction to Programming Lecture Note - 2 Visual Basic Programming Fundamentals.
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Week 1-Visual Basic: Introduction HNDIT Rapid Application Development.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 2A Reading, Processing and Displaying Data (Concepts)
Programming with Microsoft Visual Basic th Edition
Tutorial 3: Using Variables and Constants1 Tutorial 3 Using Variables and Constants.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 4 Working with Variables, Constants, Data Types, and Expressions.
CECS 5020 Computers in Education Visual Basic Variables and Constants.
Variables in VB.NET. Variables  A storage location in memory (RAM)  Holds data/information while the program is running  These storage locations can.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Numbers1 Working with Numbers There are times that we have to work with numerical values. When we count things, we need Integers or whole numbers. When.
Murach, Chapter 4. Two Data Types Value Types – Store their own data Reference Types Do not store their own data Stores a reference to an area of memory.
Variables in VB. What is a variable? ► A named memory location that stores a value.
Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 3 Variables and Calculations.
Introduction to Algorithmic Processes CMPSC 201C Fall 2000.
Making Interactive Programs with Visual Basic .NET
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.
© 2006 Lawrenceville Press Slide 1 Chapter 4 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration.
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.
Introduction to Computer CC111 Week 09 Visual Basic 2 Visual Basic Variables 1.
What will each of the following lines print? System.out.println("number" ); number645 System.out.println("number" + (6 + 4)+ 5); number105 System.out.println(6.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
1.
Egyptian Language School Computer Department
A variable is a name for a value stored in memory.
An Application Uses Variables to Hold Information So It May Be Manipulated, Used to Manipulate Other Information, or Remembered for Later Use.
BASIC ELEMENTS OF A COMPUTER PROGRAM
Visual Basic Variables
Lecture Set 4 Data Types and Variables
VB Math All of your favorite mathematical operators are available in VB: + Addition - Subtraction * Multiplication / Division \ Integer Division Mod Modulo.
Variables and Arithmetic Operations
Microsoft Visual Basic 2005 BASICS
Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions GROUPBOX CONTROL The _____________________________________.
CIS16 Application Development Programming with Visual Basic
Visual Basic Numbers Chapter 3.3 Prepared By: Deborah 1/15/2019.
CHAPTER FOUR VARIABLES AND CONSTANTS
Intro to Programming Concepts
Unit 3: Variables in Java
Visual Basic Variables
C Programming Lecture-3 Keywords, Datatypes, Constants & Variables
Visual Basic Numbers Chapter 3.3 Prepared By: Deborah 7/9/2019.
Variables and Constants
Presentation transcript:

Variables Hold information that may be manipulated, used to manipulate other information or remembered for later use A storage location in memory (RAM) Holds information while the program is running Contains Name (which cannot be changed) Data Data type is declared and cannot be changed Value for the data can be changed during the program

Things you can do with Variables Copy and store values entered by the user Perform arithmetic manipulation on values Test values to see if they meet a criteria Temporarily hold and manipulate the value of a control property Remember information for later use in the progam

Declaring a Variable Declaration statement creates the variable in memory Indicates the name to give the variable and the type of information the variable will hold DIM statement Dim VariableName as DataType

Example Dim intLength as Integer Dim intLength as Integer = 5 Dim  Stands for dimension statement Tells VB that you are creating a variable intLength  the name to give the variable As Integer  indicates that the variable will hold integer numbers = 5  assigning a beginning value to the variable

Variable Data Types See Handout Boolean (bln) Byte (byt) Char (chr) Date (dtm) Decimal (dec) Double (dbl) Integer(int) Long(lng) Object (default) (obj) Short(shr) Single(sng) String(str) User Defined

Variable Names First character must be a letter or underscore Follow 3 character prefix style After first character – you may use letters, number, underscore Cannot contain spaces or periods Using multiple words, capitalize the first letter of each word (example: intTestScore) Cannot use VB Keywords Should be meaningful

Variable Declarations Variable should be declared first in the procedure (style requirement) Variable MUST be declared prior to the code where they are used Declaring an initial value of the variable in the declaration statement is optional Will default to a value of 0

Scope of Variables Scope – the part of the program where the variable can be used Variable cannot be used before it is declared Variables declared within a procedure / event handling method is only visible to statements within that method Called Local Variables Can be declared at the beginning of the code window (General Declarations section) and be available to all methods Called Form Level Variables Cannot have more than one variable with the same cope with the same name

Lifetime of Variables Lifetime – when the variable exists in memory A variables lifetime is the execution period of the procedure/method that contains the variable When the procedure/method ends the local variables are destroyed Memory is given back to the operating system

Performing Calculations with Variables Arithmetic Operators ^ Exponential * Multiplication / Floating Point Division \ Integer Division MODModulus (remainder from division) +Addition  Subtraction &String Concatenation (putting them together)

Mathematical Order of Precedence Parenthesis Exponential Multiplication / Division Integer Division MOD Addition / Subtraction String Concatenation Relational Operators (, >=, ) Logical Operators (AND, OR, NOT)

Examples 5 * (4 + 3) – 15 Mod 2 7 * 4 / 2 - 6