Egyptian Language School Computer Department

Slides:



Advertisements
Similar presentations
Chapter 3: Using Variables and Constants Programming with Microsoft Visual Basic 2005, Third Edition.
Advertisements

Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
1 9/20/06CS150 Introduction to Computer Science 1 Review: Exam 1.
Data types and variables
Chapter 3: Introducing the Microsoft.NET Framework and Visual Basic.NET Visual Basic.NET Programming: From Problem Analysis to Program Design.
JavaScript, Third Edition
Introduction To C++ Programming 1.0 Basic C++ Program Structure 2.0 Program Control 3.0 Array And Structures 4.0 Function 5.0 Pointer 6.0 Secure Programming.
Basic Elements of C++ Chapter 2.
Copyright © 2001 by Wiley. All rights reserved. Chapter 3: Variables, Assignment Statements, and Arithmetic Variables Assignment Statements Arithmetic.
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.
Objectives You should be able to describe: Data Types
Variables and Constants
Chapter 2: Using Data.
Representing Data: Constants and Variables CHAPTER THREE Matakuliah: T0063 – Pemrograman Visual Tahun: 2009.
CPS120: Introduction to Computer Science
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
Chapter 2. C++ Program Structure C++ program is a collection of subprograms Subprograms in C++ are called FUNCTIONS Each function performs a specific.
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
CHAPTER # 2 Part 2 PROGRAMS AND DATA 1 st semster King Saud University College of Applied studies and Community Service CSC1101 By: Asma Alosaimi.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.1.
Variables & Function Calls. Overview u Variables  Programmer Defined & Intrinsic  Data Types  Calculation issues u Using Functions  The val() function.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.1.
Programming with Microsoft Visual Basic th Edition
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.
Calculator Program Explained by Arafa Hamed. First Designing The Interface Ask yourself how many places are there that will be used to input numbers?
Variables and Expressions Programming Right from the Start with Visual Basic.NET 1/e 7.
Chapter 3: Introducing the Microsoft.NET Framework and Visual Basic.NET Visual Basic.NET Programming: From Problem Analysis to Program Design.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
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.
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
Chapter # 2 Part 2 Programs And data
A variable is a name for a value stored in memory.
Chapter 2 Variables.
Chapter Topics The Basics of a C++ Program Data Types
Chapter 1.2 Introduction to C++ Programming
BASIC ELEMENTS OF A COMPUTER PROGRAM
Data Types, Arithmetic Operations
Basic Elements of C++.
Data Types, Identifiers, and Expressions
3rd prep. – 2nd Term MOE Book Questions.
Java Programming: From Problem Analysis to Program Design, 4e
3rd prep. – 2nd Term MOE Book Questions.
Basic Elements of C++ Chapter 2.
IDENTIFIERS CSC 111.
Chapter 10 Programming Fundamentals with JavaScript
Data Types, Identifiers, and Expressions
Chapter 3: Introduction to Problem Solving and Control Statements
Numbers.
Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions GROUPBOX CONTROL The _____________________________________.
CIS16 Application Development Programming with Visual Basic
CS111 Computer Programming
Chapter 2 Variables.
Chapter (3) - Looping Questions.
C++ Data Types Data Type
Chapter # 2 Part 2 Programs And data
Chapter 2: Introduction to C++.
An Introduction to Programming with C++ Fifth Edition
Primitive Types and Expressions
Chapter 2 Variables.
Chapter 2 Primitive Data Types and Operations
Variables and Constants
Presentation transcript:

Egyptian Language School Computer Department Third Prep. 2nd Term Chapter 1

The program user can enter values with different types: Name, Address, Level  Text (letters+ number + symbols) Age ,Total Grades  Numeric (Whole number or fraction number) Gender  Boolean (True / False) Birth date  Date (date / time) Favorite Color  Color

Why we have to learn the different data types? Each data type has a way in which are stored in computer memory(RAM): This is mainly for using the computer memory optimally, In terms of storage space and arithmetic and logical operations that take place on these values Each Data Type has : Storage Space in the memory Range of values (the values that can be represented by this type)

Data Types 1- Numerical 3- Miscellaneous Data Types 2- Character Data Type A- Integral String Char Object Date Boolean Byte Short Integer Long range 0255 Storage space 4bytes B- Non-integral Single Double Decimal

It`s clear that properties are data storage location and their values have a specific data type For Example: The property Text  String The property AutoSize Boolean The property Width Integer VB.Net Supports types other than the standard Data types like Font , Color , ………..etc The property BackColor Color

Variables Are reserved memory locations to store values temporarily which have: Names Data Types Note: These Values can be changed during program execution

Variable Declaration Dim VariableName As DataType Example : Dim V_ Name As String Dim Age As Byte Dim Area As single Dim Gender As Boolean Dim B_Date As Date Dim Level As Char

Naming Variables √ Consists of letters, numbers & Underscores(_) √ Must begin with a letter or underscore(_) √ It’s preferable that variable names reflect s its contents. × Shouldn't contain symbols, special characters ( * ,?, !, .) × Don’t use reserved words such as (Dim, Single , As)

Test your self State whether the variable name is valid or not according to the naming rules Variable name Validation Dim 1A as single Dim Stud name As string Dim Class-name As string Dim Stud_grade As Double Dim Date As Integer Dim R As Double Not Valid Not Valid Not Valid Valid Not Valid Valid

Constants They are reserved memory places that have a data type. Declaring constants means to assign values to them , these values can’t change during program execution.

Declaration Rule Const Pi As single = 22/7 Const Constant name As Data Type (= Value) Const Pi As single = 22/7 Const BirthDate As Date = #1/24/2002# Const Country As String = “ Egypt”

Comparison between Variables and Constants They are reserved places in computer memory(RAM) declared and determined by their names and data types. Their values can be changed during the running of the program . They take fixed value and can`t change during the progress of the program . Declaration in VB.Net is done by the key word or the command ( DIM ) And the declaration statement is: DIM Variable as Data = [initial value] Name Type Declaration in VB.Net is done by the key word or the command ( Const ) Const Constant as Data = Value Name Type Assigning initial value to variables during declaration is optional. Assigning value to constants during declaration is a must. Such as : price of product - value of the tax – address – Birthrate of student - Gender – no. of books in the library. etc…. Such as : mathematical constants like (Ԓ) – Some physics constants like gravity acceleration , the speed of light and speed of sound.etc….

Scope of Variables Variables & constants can’t be used except in the scope of their declaration. We can declare variables & constants on a class level & then we don’t the declaration process at each scope of the Event procedure.

The assignment statement Left side Assignment Operator Right side Variable Or Property = Abstract value or Value from the variables or Property or Value from an Expression

Assignment Examples The Right side of the Equation could be Dim Number1, Number2 AS Integer Dim Salary As single = 650.5 Abstract value Number1=5 Value from a variable Number2=Number1 Value from a property Name=TextBox1.Text Value from Expression Salary= Salary /3

We use the variables through an assignment statement after declaration Using Variables We use the variables through an assignment statement after declaration If the variable is on the right side of the assignment statement, this indicates that values stored in variables . Dim U_Name As String U_ Name = Textbox1 . Text If the variable is on the right side of the assignment statement, this means that it reflects (outputs) its value. Dim U_Name As String= “ Mai” Textbox2 . Text = U_ Name

The Idea of the program In this program we will make assignments of inputs received from the user to their corresponding variables then reflects their values in control (Label5)

The idea of the Program In this program we will make assignments of inputs received from the user to their corresponding variables then reflects their values in the control (label5)

Me.Label5.Text = u_name & vbCrLf & u_D_B & vbCrLf & _ u_gender & vbCrLf & u_C_F Keyword function Me Express the current form (the control is on the same form where we write the codes) & Concatenation ( to append or join text of the codes together) vbCrLf Values of Variables are separated from each other by new line. (_) or underscore Enables writing lines of code in more than one line (to organize and simplify the process of reading codes) Rem or Appostrophe ( ‘ ) To indicates the line of code as comment (what`s written after is neglected and isn`t considered by the compiler while program execution )

Priority Rules for Arithmetic Operations (Operator Precedence) ( ) (from inside to out) ^ (exponent/ raise to the power) * / (from left to right) + - (from left to right) Solve: A= (2*(3^2)/ 3-1).

There are 3 types of errors Syntax Errors Logical Errors Runtime Error There are 3 types of errors

Din X As Byte - Dim Area As Sengl Syntax Errors this type of error is easy to detect because the IDE helps and displays the syntax of any command as we type it Refers to the spelling mistakes in writing the reserved words or error in the common syntax commands of the language. Din X As Byte - Dim Area As Sengl Din instead of Dim and Sengl instead of single Const PI As single No value assigned to constant PI during the declaration.

Logical Errors this type of error happens when we get incorrect results after executing the program Due to the wrong formulating in arithmetic or logic expressions Area = Pi + Radius ^ 2 On running the program , It will give wrong result because we used sign (+) instead of (*) To overcome this type of error, review the written code, and test the program with data already validated to check .

Runtime Errors this type of error is discovered when the program is running Due to assigning value lesser or greater than the range of the data type declared or not compatible with the data type of the variable. Dim Age As Byte Age = 500 or Age = - 10 it shows Overflow which means out of range Age =“ five” it assigns string value instead of numeric value as declared