Variables and Constants

Slides:



Advertisements
Similar presentations
Ch. 3 Variables VB.Net Programming. Data Types Boolean – True or False values Short – Small integers (+/- 32,767) Integer – Medium-size integers (+/-
Advertisements

What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
Names and Bindings.
Chapter 7: User-Defined Functions II
Chapter 7: User-Defined Functions II Instructor: Mohammad Mojaddam.
VBA Modules, Functions, Variables, and Constants
Arrays Array of Controls: several controls, of the same type (Class: a prototype for an object indicating the properties and methods), that have the same.
Java An introduction. Example 1 public class Example1 { public static void main (String [] args) { System.out.println (“This is the first example”); int.
Data Types and Operations Programming Fundamentals (Writing Code)Programming Fundamentals (Writing Code)
VB Code Statements 3 types of VB statement The Remark statement, known as comments, are used for project documentation only Begin with an apostrophe Not.
To type the VB code behind the command button (named cmdPush), Double-Click on the Push Me (caption) command button As a result the Visual Basic Code Window.
Arrays Array of Controls: several controls, of the same type (Class: a prototype for an object indicating the properties and methods), that have the same.
Names and Bindings Introduction Names Variables The concept of binding Chapter 5-a.
VB DATATYPES, VARIABLES, CONSTANTS & CALCULATIONS.
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.
Names Variables Type Checking Strong Typing Type Compatibility 1.
National Diploma Unit 4 Introduction to Software Development Data types, variables and constants.
CPS120: Introduction to Computer Science Variables and Constants Lecture 8 - B.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition, Fifth Edition Chapter 7: User-Defined Functions II.
Access VBA Programming for Beginners - Class 2 - by Patrick Lasu
VARIABLES & CONSTANTS. Objective By the end of the lesson students should be able to:  Define a constant  Define a variable  Understand the rules for.
3 - Variables Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
CPS120: Introduction to Computer Science
COMP102 Lab 081 COMP 102 Programming Fundamentals I Presented by : Timture Choi.
1 © 2002, Cisco Systems, Inc. All rights reserved. Arrays Chapter 7.
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Chapter 05 (Part III) Control Statements: Part II.
SQL Fundamentals  SQL: Structured Query Language is a simple and powerful language used to create, access, and manipulate data and structure in the database.
Pointers: Basics. 2 What is a pointer? First of all, it is a variable, just like other variables you studied  So it has type, storage etc. Difference:
Computer Engineering 1 st Semester Dr. Rabie A. Ramadan 3.
Introducing C++ Programming Lecture 3 Dr. Hebbat Allah A. Elwishy Computer & IS Assistant Professor
INT213-Week-2 Working with Variables. What is variable
Variable, Constants and Calculations Dr Mohammad Nabil Almunawar.
# 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?
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 7 Where Can I Store This?
Lecture – Pointers1 C++ Pointers Joseph Spring/Bob Dickerson School of Computer Science Operating Systems and Computer Networks Based on notes by Bob Dickerson.
Programming with Microsoft Visual Basic th Edition
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
COMP 102 Programming Fundamentals I Presented by : Timture Choi COMP102 Lab 011.
Variables Hold information that may be manipulated, used to manipulate other information or remembered for later use A storage location in memory (RAM)
Variables in VB.NET. Variables  A storage location in memory (RAM)  Holds data/information while the program is running  These storage locations can.
CPS120: Introduction to Computer Science Variables and Constants.
Slide 1 Controls v Control naming convention –Label: lblName –Command Button: cmdName –Text Box: txtName.
Variables in VB. What is a variable? ► A named memory location that stores a value.
 Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. 
Creation of Variables with Numeric, alphanumeric, date, picture, memo data types Constant - A quantity that does not change during the execution of a program.
B065: PROGRAMMING Variables 2. Starter  What is wrong with the following piece of code: Option Explicit Off Dim num1 as string Dim num2 as integer num1.
1 A more complex example Write a program that sums a sequence of integers and displays the result. Assume that the first integer read specifies the number.
Lecture 2 Arrays. Topics 1 Arrays hold Multiple Values 2 Accessing Array Elements 3 Inputting and Displaying Array Contents 4 Array Initialization 5 Using.
+ Note On the Use of Different Data Types Use the data type that conserves memory and still accomplishes the desired purpose. For example, depending on.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Unit 2 Technology Systems
A variable is a name for a value stored in memory.
Chapter 7: User-Defined Functions II
Programming constructs
Visual Basic Variables
Introduction to Python Data Types and Variables
C Language VIVA Questions with Answers
Constant Variable Expression
Microsoft Visual Basic 2005 BASICS
Introduction To Programming Information Technology , 1’st Semester
CHAPTER FOUR VARIABLES AND CONSTANTS
Introduction to Data Structure
Intro to Programming Concepts
Variables and Computer Memory
B065: PROGRAMMING Variables 2.
C Programming Lecture-3 Keywords, Datatypes, Constants & Variables
Variables and Constants
Presentation transcript:

Variables and Constants Variables: Memory locations that hold data, that can be changed during project execution (eg: student names will vary as the information for each student is being processed) Constants: Memory locations that hold data that cannot change during execution (eg: however, the college which the students attend (UCC) will remain the same)

Variables Variables are declared, depending on where they are used and how long their value needs to be retained Variables are locations in the computers memory, which are named by the user Variables store values The values which are assigned to variables can change during project execution (the values they hold varies, hence the name)

Variables have to be declared (the computer must be made aware of their existence) and once they have been declared, the computer allocates them (memory) storage space and assigns this area of memory a name, called an identifier Variables are declared using the DIM statement DIM Variable Name (Identifier) AS Data Type The declaration statements establish the project variables, assign names to the variables, and specify the type of data that the variables will hold The statements are non-executable (they are not executed in the flow of instructions during program execution

Dim stName As STRING (Declares a string variable) Dim iCounter As INTEGER (Declares an integer variable) The reserved word DIM is short for dimension, meaning size Variables can have a number of different data types A variable can only store values which correspond with the data type they are assigned

Data Types The data type of a variable indicates what type of information will be stored in the allocated memory space The default data type is variant The advantage of using variant data type is that it is easy, and the variables change their appearance as needed for each situation The disadvantage is that variants are less efficient than the other data types, they require more memory and operate less quickly

Variable Declarations DIM Variable name (Identifier) AS Data Type Dim iYear As Integer Dim stCustName As String can also be declared as: Dim iYear As Integer, stCustName As String Also Specific Characters can be used to represent each of the Data Types

Data Types - String ($) - Integer (%) - Currency (@) - Long Integer (&) - Single Precision (!) - Double Precision (£) Variable Declarations Dim iYear%, stCustName$, cInterest@