VB Variables and Data 091200.

Slides:



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

Lecture Set 4 Data Types and Variables Part B – Variables, Constants, Expressions Conversion Rules Options Strict, Option Explicit Scope of Definition.
Introduction to Computing Concepts Note Set 7. Overview Variables Data Types Basic Arithmetic Expressions ▫ Arithmetic.
Data Types in Java Data is the information that a program has to work with. Data is of different types. The type of a piece of data tells Java what can.
10-Jun-15 Introduction to Primitives. 2 Overview Today we will discuss: The eight primitive types, especially int and double Declaring the types of variables.
©2004 Brooks/Cole Chapter 2 Variables, Values and Operations.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
1 Chapter 3 Arithmetic Expressions. 2 Chapter 3 Topics l Overview of Java Data Types l Numeric Data Types l Declarations for Numeric Expressions l Simple.
Fundamental Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
Chapter 2 Data Types, Declarations, and Displays
Chapter 3: Introducing the Microsoft.NET Framework and Visual Basic.NET Visual Basic.NET Programming: From Problem Analysis to Program Design.
VB .NET Programming Fundamentals
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.
Variables & Math Operators CE 311 K - Introduction to Computer Methods Daene C. McKinney.
Objectives You should be able to describe: Data Types
National Diploma Unit 4 Introduction to Software Development Data types, variables and constants.
IMS 3253: Math 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Five Fundamental Math Operations Precedence of Math.
Lesson 3 – Primitive Data Types Objective: Students will investigate the definition and usage of objects and primitive data types in Java in order to practice.
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Programming Process Programming in Java is an exercise in using pre-defined classes and writing new classes to fill in the gaps A procedure for determining.
IFS Intro to Data Management Chapter 5 Getting More Than Simple Columns.
Copyright Curt Hill Variables What are they? Why do we need them?
Variables & Function Calls. Overview u Variables  Programmer Defined & Intrinsic  Data Types  Calculation issues u Using Functions  The val() function.
CNS 1120 Exam 1 Review. Programming Language Elements Syntax = the rules to follow Syntax = the rules to follow Semantics = the meaning of symbols Semantics.
INT213-Week-2 Working with Variables. What is variable
Variable, Constants and Calculations Dr Mohammad Nabil Almunawar.
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Data Tonga Institute of Higher Education. Variables Programs need to remember values.  Example: A program that keeps track of sales needs to remember.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 2A Reading, Processing and Displaying Data (Concepts)
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.
Computer Science I Storing data. Binary numbers. Classwork/homework: Catch up. Do analysis of image types.
Variables Hold information that may be manipulated, used to manipulate other information or remembered for later use A storage location in memory (RAM)
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.
Chapter 14 JavaScript: Part II The Web Warrior Guide to Web Design Technologies.
VB.NET 2008 Introduction to Variables Part 1. Overview.NET Languages –Source Code –Compiler –MSIL –CLR & Windows Variables –Data Types –Converting.
CS 106 Introduction to Computer Science I 09 / 10 / 2007 Instructor: Michael Eckmann.
CIS 338: VB Variables Dr. Ralph D. Westfall April, 2011.
Making Interactive Programs with Visual Basic .NET
Java Programming: Guided Learning with Early Objects Chapter 1 Basic Elements of Java.
Chapter 2 Variables.
Topics Designing a Program Input, Processing, and Output
Chapter 2 Basic Computation
An Application Uses Variables to Hold Information So It May Be Manipulated, Used to Manipulate Other Information, or Remembered for Later Use.
Visual Basic Variables
Data Types, Arithmetic Operations
ITEC113 Algorithms and Programming Techniques
REALLY BIG & REALLY small Numbers
2. Understanding VB Variables
Lecture Set 4 Data Types and Variables
Chapter 2 Basic Computation
Chapter 6 Variables What is VBScript?
Numbers.
Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions GROUPBOX CONTROL The _____________________________________.
Arithmetic Expressions & Data Conversions
Chapter 2 Variables.
CSI 101 Elements of Computing Spring 2009
Visual Basic Numbers Chapter 3.3 Prepared By: Deborah 1/15/2019.
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Introduction to Primitives
Fundamental OOP Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
Introduction to Primitives
In this class, we will cover:
Unit 3: Variables in Java
Chapter 2 Variables.
Visual Basic Numbers Chapter 3.3 Prepared By: Deborah 7/9/2019.
The Fundamentals of C++
Arithmetic Expressions & Data Conversions
Presentation transcript:

VB Variables and Data 091200

About this Presentation Do not feel you have to memorize all the technical details yet. Know it well enough that you know you need to look it up when needed. Know the basics.

Types of data Variable Constant Literal

Variables A variable is like a box in the computer memory for holding values. Depending on the memory requirements of the variable, we may specify a large or small box. Dim intAge as Byte Dim curNationalDebt as Currency

A constant is a variable that doesn’t vary! In other words, you may specify a value, such as PI, that you never want to change in your program.

Literal A literal is a number that does not take up a variable position. You simply refer to that number, such as 7 in this example: intHumanYears = intDogAge * 7

2 General Variable Types Numeric NonNumeric

2 Basic types of Numeric Variables Integer Decimal

Integer types Byte (0-255) 1 byte: 256 values Integer (-32,768 to 32,767) 2 bytes: 256^2 values Long (-2,147,483,648 to 2, 147,483,647) 4 bytes: 256^4 values

A relevant tangent…

A computer is really just a bunch of on/off switches These switches, bits, come in sets of 8, called bytes

A single byte is 8 on/off switches containing 256 possible values: 0 1 0 2 0 4 0 8 0 16 0 32 0 64 0 128

The zeros represent OFF, the ones ON. This number is 49 1 1 0 2 0 4 0 8 1 16 1 32 0 64 0 128

Now that we have discussed integers we shall discuss decimal variables

Decimal types Decimal types aren’t as simple as integer types, but still use bytes.

Decimal types Single 38 or more places 4 bytes Double 308 or more places 8 bytes Currency (-922 trillion to 922 trillion) 8 bytes

Scientific Notation 1.44E+5 = a number with the decimal shifted 5 places to the right: 144,000 1.44E-5 = a number preceded by 5 zeros 0.0000144

Forcing a Literal Occasionally you may want to force a literal number to be more precise so the computer allocates enough memory for a calculated result. & Long ! Single # Double @ Currency

For instance… To add 7 to the curNationalDebt, you may refer to it as 7@

Other Literals Date - Date Literal #September 1, 1964# String - String Literal “Enclosed in Quotes”

NonNumeric Data Types

Nonnumeric Data Strings Text length+10 bytes Boolean True/False 2 bytes used Date Various date formats 100AD to 9999AD Variant All types of data Numeric data uses 16 bytes String data uses Length + 22 bytes Object The reference to an object

For this class, use variable prefixes: Boolean blnYesOrNo Byte bytAge Currency curNationalDebt Date dteBirthday String strMyName Variant vntUsesMemory continued

For this class, use variable prefixes: Double dblKilometersToMars Integer intStudentsAtMyHighSchool Long lngUSPopulation Object objMyStats Single sngDistanceToMoon

How do you USE Variables… Now that we have discussed them… How do you USE Variables…

Remember all of this next part…

First, lets tell the computer to help us. Add Option Explicit To the first line of your code, in the general declarations part of your code. This catches misspelled variables that could cause you grief It minimizes the chances of you using one name for two different intended variables.

Make your variable boxes, and make them the right sizes. Dim bytAge as Byte Dim datMyDOB as Date Dim strMyName as String This is also done in general declarations, OR in a subroutine. If done in a subroutine it is used locally – in that subroutine only.

The variables are empty. You may now fill them as needed. Let bytAge=36 or simply bytAge=36

And you can do math… ^ Exponentiation bytYourAge=2^2 * Multiplication bytAge=9*4 / Division byYourAge=24/3 + Addition bytAge=30+6 - Subtraction bytAge=40-4 let bytAge=bytYourAge * 4.5 NOTE: Your book has errors in this (Table 5.5)

And more… MOD Modulus intMyRemainder = 11 MOD 3 MOD only works with Integers. \ Whole number division intMyWholePart = 11\3 intMyRemainder = 2, and intMyWholePart = 3 Because 11/3 is 3 remainder 2

Concatenation Concatenation means joining strings We could use + or & but we won’t use the + We will use "&" because it is easier to understand and distinguish from math

Math Operation Priority Parentheses Exponentiation Multiplication, Division, Integer Div, MOD Addition/Subtraction Left to Right Do some math examples!