VB DATATYPES, VARIABLES, CONSTANTS & CALCULATIONS.

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

Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
L2:CSC © Dr. Basheer M. Nasef Lecture #2 By Dr. Basheer M. Nasef.
Variables and Constants
1.
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
Java An introduction. Example 1 public class Example1 { public static void main (String [] args) { System.out.println (“This is the first example”); int.
1 Key Concepts:  Data types in C.  What is a variable?  Variable Declaration  Variable Initialization  Printf()  Scanf()  Working with numbers in.
Chapter 31 Fundamentals of Programming in VB(Continue I) Numbers Arithmetic Operations Variables Incrementing the Value of a Variable.
Chapter 3: Introducing the Microsoft.NET Framework and Visual Basic.NET Visual Basic.NET Programming: From Problem Analysis to Program Design.
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.
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.
Chapter 8: String Manipulation
Variables, Constants, Methods, and Calculations Chapter 3 - Review.
Variables and Constants
Chapter 3: Using Variables and Constants
Programming with Microsoft Visual Basic th Edition CHAPTER THREE USING VARIABLES AND CONSTANTS.
Variables and Data Types
Chapter 2 Primitive Data Types and Operations F Introduce Programming with an Example  The MyInput class F Identifiers, Variables, and Constants F Primitive.
1 Chapter 2 Primitive Data Types and Operations F Introduce Programming with an Example  The MyInput class F Identifiers, Variables, and Constants F Primitive.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Interest Calculator Application Introducing the For...Next Repetition Statements.
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
CHAPTER THREE Representing Data: Constants and Variables.
Chapter 2: Using Data.
3 - Variables Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
Lecture #5 Introduction to C++
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.
Applications Development
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
Variables & Function Calls. Overview u Variables  Programmer Defined & Intrinsic  Data Types  Calculation issues u Using Functions  The val() function.
Programming with Microsoft Visual Basic th Edition
Tutorial 3: Using Variables and Constants1 Tutorial 3 Using Variables and Constants.
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.
1 Writing Software Kashef Mughal. 2 Algorithms  The term algorithm (pronounced AL-go-rith-um) is a procedure or formula for solving a problem.  An Algorithm.
Variables and Expressions Programming Right from the Start with Visual Basic.NET 1/e 7.
 Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. 
Visual Basic.NET Programming for the Rest of Us Keith Mulbery Utah Valley State College.
CIS 338: VB Variables Dr. Ralph D. Westfall April, 2011.
1 1 Chapter 2 Elementary Programming. 2 2 Motivations In the preceding chapter, you learned how to create, compile, and run a Java program. Starting from.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
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.
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.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Introduction to Programming Lecture 2
A variable is a name for a value stored in memory.
BASIC ELEMENTS OF A COMPUTER PROGRAM
Visual Basic Variables
Chapter 3: Using Variables and Constants
Variables and Arithmetic Operations
Microsoft Visual Basic 2005 BASICS
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 _____________________________________.
Variables T.Najah Al_Subaie Kingdom of Saudi Arabia
Additional Topics in VB.NET
CHAPTER FOUR VARIABLES AND CONSTANTS
Intro to Programming Concepts
Chapter 2 Primitive Data Types and Operations
Variables and Constants
Presentation transcript:

VB DATATYPES, VARIABLES, CONSTANTS & CALCULATIONS

Visual Basic Events When a Visual basic program runs, the form and its controls appear on the screen ‘action’. clicking a control pressing a key an event such as clicking a control or pressing a key. We call such an action an event. The programmer writes code that reacts to an event by performing some functionality. three steps The three steps in creating a VB.NET program :

Visual Basic Events  Create the interface  Create the interface generate, position, and size the objects.  Set properties  Set propertiesconfigure the appearance of the objects.  Write the code  Write the code executes when events occur. Event-driven programming where the programs allow responding to many different input or events. This is called Event-driven programming where the programs allow responding to many different input or events.

VISUAL BASIC.NET DATA TYPES Data type Data type is a class that is primarily used just to hold type of data of variables…

.NET Data types Data TypeSize in BytesDescriptionType Byte18-bit unsigned integerSystem.Byte Char216-bit Unicode charactersSystem.Char Integer432-bit signed integerSystem.Int32 Double8 64-bit floating point variable System.Double Long864-bit signed integerSystem.Int64 Short216-bit signed integerSystem.Int16 Single4 32-bit floating point variable System.Single StringVariesNon-Numeric TypeSystem.String Date8System.Date Boolean2Non-Numeric TypeSystem.Boolean Object4Non-Numeric TypeSystem.Object Decimal bit floating point variable System.Decimal

Properties in VB controls also have data types, and when we assign values to the properties, those values must be of proper data type. Think back to some of the properties we have been using -- each has its own data type: Property Data Type namestring Textstring visibleboolean multilineboolean

VARIABLES store Used to store data in memory., and later retrieve them. names, data types, and values Like the properties of objects, variables have names, data types, and values. As the name implies, the values of variables can change (vary) during the execution of the program.

The name, data type and an optional initial value of each variable is specified with a D DD Dim statement. Dim stands for Dimension. D Dim <variable name> as <data type> [=expiration] when the Dim statement is executed the compiler sets aside space in memory to hold it's value. (The amount of memory it needs to set aside depends upon the data type).

For example: For example: consider the following Dim statements: Dim strName As String = "Bob" Dim intAge As Integer = 21 Dim sglPay As Single = 7.50 When the computer executes these instructions, it would construct three variables, setting aside space in memory for each and assigning it the appropriate initial values

WWe made up variable names that indicate the data type (str, int, sgl) and the meaning (name, age, pay rate). AA variable name can be anything you wish, but words that have specific meaning in Visual Basic, like "Dim" or "CInt," are r rr reserved words (or Keywords) and cannot be used as variable names. NNote: The syntax of the Dim statement indicates that expression giving the initial value is optional. If it is not specified, numeric variables are assigned an initial value of zero (0) and string variables are assigned an initial value of Null ("").

Examples: Initialization !! Numeric variables are automatically initialized to 0: Dim varName As Double To specify a nonzero initial value Dim varName As Double = 50 Or Dim varName As Double VarName = 50

Cont.. Examples: Incrementing !! To add 1 to the numeric variable var var = var + 1 Or as a shortcut var +=1

copy Cont.. Examples: Integer Data Type !! An integer is a whole number.. Declaring an integer variable: Dim varName As Integer Multiple Declarations Dim a, b As Double Two other types of multiple-declaration statements are Dim a As Double, b As Integer Dim c As Double = 2, b As Integer = 5