Creation of Variables with Numeric, alphanumeric, date, picture, memo data types Constant - A quantity that does not change during the execution of a program.

Slides:



Advertisements
Similar presentations
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Advertisements

L2:CSC © Dr. Basheer M. Nasef Lecture #2 By Dr. Basheer M. Nasef.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Input Validation Check the values entered into a text box before beginning any calculations Validation is a form of ‘self-protection’, rejecting bad data.
1 Pertemuan 03 Representing Data Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
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.
Chapter Three Using Variables and Constants Programming with Microsoft Visual Basic th Edition.
Variables and Constants
Chapter 3: Using Variables and Constants
CS0004: Introduction to Programming Variables – Numbers.
© 1999, by Que Education and Training, Chapter 5, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach.
Saeed Ghanbartehrani Summer 2015 Lecture Notes #4: Working with Variables and User Interfaces IE 212: Computational Methods for Industrial Engineering.
2440: 211 Interactive Web Programming Expressions & Operators.
Microsoft Visual Basic 2005 BASICS Lesson 4 Mathematical Operators.
Review for Mid-term! October 26, Review Homework Worksheet True or False Operators are symbols that perform specific operations in Visual Basic.
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.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
CHAPTER 4: CONTROL STRUCTURES - SEQUENCING 10/14/2014 PROBLEM SOLVING & ALGORITHM (DCT 1123)
C++ Programming: Basic Elements of C++.
Constants Numeric Constants Integer Constants Floating Point Constants Character Constants Expressions Arithmetic Operators Assignment Operators Relational.
Fundamentals of GUI Programming. Objectives: At the end of the session, you should be able to: describe the guidelines that are used for creating user-friendly.
Using Data Within a Program Chapter 2.  Classes  Methods  Statements  Modifiers  Identifiers.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Lecture 2: Introduction to C Programming. OBJECTIVES In this lecture you will learn:  To use simple input and output statements.  The fundamental data.
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.
Overview of VBA Programming & Syntax. Programming With Objects u Objects –Properties: attributes or characteristics of an object (e.g., font size, color,
Variables & Function Calls. Overview u Variables  Programmer Defined & Intrinsic  Data Types  Calculation issues u Using Functions  The val() function.
INT213-Week-2 Working with Variables. What is variable
1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.
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.
Hungarian Notation A must in this course Every object used MUST be renamed including the form(s) using the following rules Form  frmFormName E.g. frmTemperature.
Part:2.  Keywords are words with special meaning in JavaScript  Keyword var ◦ Used to declare the names of variables ◦ A variable is a location in the.
Variables Hold information that may be manipulated, used to manipulate other information or remembered for later use A storage location in memory (RAM)
Chapter 4 Getting Started with VBA. Subroutines Subroutine is the logical section of code that performs a particular task. Subroutine is also called a.
CECS 5020 Computers in Education Visual Basic Variables and Constants.
Controlling Program Flow with Looping Structures
Slide 1 Controls v Control naming convention –Label: lblName –Command Button: cmdName –Text Box: txtName.
Variables and Expressions Programming Right from the Start with Visual Basic.NET 1/e 7.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 11 So Many Paths … So Little Time.
Data and variables in Visual Basic. Annoucement Lecture on Thursday 7:30PM C106 Visual Basic download: 
Knowledge Base. Defining a Variable Dim statement Dim intXX As Integer Public in a Module Public dblNN As Double.
C Building Block Chapter 2. Variables A variable is a space in the computer’s memory set aside for a certain kind of data and given a name for easy reference.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
Subroutines (PrArith, Math,projCP1, PrAdrProc, PrAdrProcFunc) Please use speaker notes for additional information!
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.
Programming with Microsoft Visual Basic 2012 Chapter 3: Using Variables and Constants.
Chapter 3 - VB 2008 by Schneider1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 Input and Output.
© 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.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Visual Basic/ Visual Studio Brandon Large. Connecting to prior knowledge In your notes write down what the two main parts of the computer are. The “software”
A variable is a name for a value stored in memory.
BASIC ELEMENTS OF A COMPUTER PROGRAM
Visual Basic 6 (VB6) Data Types, And Operators
Variables, Expressions, and IO
2. Understanding VB Variables
Chapter 6 Variables What is VBScript?
Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions GROUPBOX CONTROL The _____________________________________.
CIS16 Application Development Programming with Visual Basic
T. Jumana Abu Shmais – AOU - Riyadh
Fundamentals of visual basic
Introduction to Programming
DATA TYPES AND OPERATIONS
Presentation transcript:

Creation of Variables with Numeric, alphanumeric, date, picture, memo data types Constant - A quantity that does not change during the execution of a program is called constant. Constant types are 1) Numeric constant 2) String constant 1)Numeric constant : It is nothing but number. Number can be expressed as integer quantities (whole number) or as decimal quantities (number with decimal point) example : )String constant: A string is a sequence of characters (ie letters, numbers and special symbols such as +, $ etc) example: “RAJA” “JAMES BOND 007” “1234$”

Variable - A quantity that does change during the execution of a program is called variable. A variable is a data name that may be used to store a data value. - The address of the memory location is called variable. Rules :- - First character must be a letter - Maximum length of variable name is 255 characters. - The variable name should not be a Keyword. - It can contain only letters, numbers or the underscore character Ex : area, Area, AREA, sum, sum1, net_amount Variable types are 1) Numeric variable 2) String variable. 1)Numeric variable : It is the address of memory location that can hold only numeric constant. example : x = 124 net_amount = sum1 = 1299 z = )String constant: It is the address of memory location that can hold only string constant. example: a = “RAJA” name = “JAMES BOND 007” y = “1234$”

Data Types Every application or program needs to process some data to generate the required output. All these data values need to be of different types. It can be classified into two types 1) Fundamental data types  Which is already defined by developer 2) User defined data  Which are created (or defined) by the user at the time of program or application writing. 1)Fundamental data types: VB provides the following fundamental data types are: –Byte –Boolean –Integer –Long –Single –Double –Currency –Object –Date –String –Variant

TypeStorageRange Byte1 byte0 to 255 Integer2 bytes to Long4 bytes to Double8 bytes E+308 to E-324 for negative values; E-324 to E+308 for positive values Currency8 bytes to Decimal12 bytes +/ with no decimal and +/ with up to 28 decimal places

Data TypeStorageRange String (fixed length)length of string1 to characters String (variable)length + 10 bytes0 to 2 billion characters Date8 bytesJan 1, 100 to Dec 31, 9999 Boolean2 bytestrue or false Object4 bytesany embedded object Variant (numeric)16 bytes any value as large as Double Variant (text)length + 22 bytes same as variable length string

Boolean data, represents data that can take only two values. These values are represented as either true or false. Variant is the default data type in VB. If the data type is not specified to a variable, then the variable is said to have variant data type. Declaration of Variables: (DIM statement ) VB allows you to declare and store values in variables. Syntax: DIM [As ] Examples: DIM name as string DIM id as integer DIM dob as date DIM sex as Boolean Example DIM name Here variable name is variant data type and can store any data suppose name = “Rama”  here name is a string type variable name = 125  here name is a integer type variable name = True  here name is a Boolean type variable name = 77.8  here name is a double type variable

Operators 1) Arithmetic Operators OperatorMeaningExampleResult ^Exponent2 ^ 38 *multiplication5 * 840 /division40 / 85 +addition subtraction &concatenation"Hi " & "There""Hi There"

Hierarchy of Arithmetic operators VB performs math calculations in strict order. The following image illustrates the order of operations

2) Comparison Operators (conditional /Relational)

3) Logical Operators OperatorMeaning ANDReturns TRUE if both Boolean expression are TRUE OR Returns TRUE if either Boolean expression is TRUE NOT Returns TRUE if Boolean expression is FALSE Or Returns FALSE if Boolean expression is TRUE

The Assignment Statement Once a variable is declared, it is ready to use. You store values in variables using the assignment statement( = is a assignment operator). Here is the format for the assignment statement: ItemName = constant / expression/ control’s propery ItemName can be a variable or a control property value. Here are examples of each in respective order: X = 10 sum = a * 0.14 / 2 Name =“Rajive” Label1.caption = “Enter First number”

MsgBox: It is one of the function. It is used to display customized messages to the users. Syntax: Variable = MsgBox(Prompt [,buttons][,title][,helpfile,context]) Here Prompt  is the message that is displayed Button  determine the type of buttons,

title  refers to the title of the message box. Ex: choice = MsgBox ( “Are you ready to print ?”, VbOkCancel,”Killikulam” ) Title Message Or choice = MsgBox ( “Are you ready to print ?”, 1,”Killikulam” ) Buttons

Ex : 2 s = 100 MsgBox ("The sum " & Str(s))

Input Box: This function displays a message box and allows the user to enter a value that your program can respond to. An input box is simply a message box with a field in which the user can type a value, such as a word or phrase that might answer a question you ask. Unlike message boxes, you cannot control which command buttons appear in an input box and you cannot place an icon in it as well. Syntax: Variable = InputBox (Prompt [, Title] [,Default] [,xpos][,ypos]) Here Prompt  is the message that is to be displayed Title  is the title of the Input box message box xpos, ypos  are the position where the InputBox is to be displayed. Ex:1 r = InputBox("Enter Radius", "Killikulam")

s = InputBox("Enter Your Sex", "Killikulam", "Mail")

Design a VB form to find area of circle Private Sub Command1_Click() Dim r As Double Dim area As Double r = InputBox("Enter Radius", "Killikulam") area = 3.14 * Val(r) * Val(r) MsgBox ("The area of Circle = " & area) End Sub