lesson 4 visual basic data

18
ANALYZING VISUAL BASIC DATA

Upload: christopher-olaya

Post on 14-Apr-2017

554 views

Category:

Education


0 download

TRANSCRIPT

Page 1: Lesson 4 visual basic data

ANALYZINGVISUAL BASIC DATA

Page 2: Lesson 4 visual basic data

VISUAL BASIC OPERATORS• Like other programming languages

may it be text oriented or object oriented type like Visual Basic, it uses five basic arithmetic operations which are addition, subtraction, multiplication, division and exponentiation.

Page 3: Lesson 4 visual basic data

The following are symbols for declaring specific operationsMathematical Operation

Operator or Symbol

Mathematical Notation

Example Result

Addition + a+b 17+2 19

Subtraction - a-b 2-17 -15

Multiplication * a*b 2*17 34

Division / a/b 17/1 17

Exponentiation ^ a^b 7^2 49

+ or & String Concatenations

String1 + String2 or String1 & String2

“Hello” + “World”

Hello World

mod Reminder of division

a mod b 19mod3 1

Page 4: Lesson 4 visual basic data

The following are symbols for declaring specific operations• Visual Basic follow the precedence of the

formula like in Math wherein if follow the rules of EMDAS.

• Use parenthesis to alter the precedence followed by EMDAS. Expressions inserted inside a parenthesis will be executed first before the other expressions.

Page 5: Lesson 4 visual basic data

RELATIONAL OPERATORS

Operators Description Mathematical Notation

Example Result

> Greater than a>b 25>2 True

< Less than a<b 25<5 False

>= Greater than or equal to

a>=b 83>=75 True

<= Less than or equal to

a<=b 83<=75 False

< > Not equal a< >b Password<> computer

True

= Equal a = b Password = computer

False

Page 6: Lesson 4 visual basic data

LOGICAL OPERATORS

Operators Description Example ResultOR It will retrieve true value if the

operand are true.(25>3) OR (3<5) True

AND It will retrieve true value only if both operands are true

(25>3) AND (3<5) True

XOR Both must not be true meaning only one side should hold true value

(25>3) XOR (3<5) False

NOT Reverse true side NOT (2=2) False

Page 7: Lesson 4 visual basic data

Example

Page 8: Lesson 4 visual basic data

KINDS OF DATA TYPES1. Numeric – a data type that holds whole numbers.

Two Categorya. Integers – which are whole numbers and without

decimal.b. Decimal – holds numbers with decimal points

that usually represent fractional values like 3.1426, -22, etc.

.

Page 9: Lesson 4 visual basic data

KINDS OF DATA TYPESSeven Numeric Data Types

Type Storage RangeByte 1 byte 0 to 255

Integer 2 bytes -32,768 to 32,768

Long 4 bytes -2,147,483,648 to 2,147,483,648

Single 4 bytes -3.402823E+38 to -1.401298E-45 or1.401298-45 to 3.402823E+38

Double 8 bytes -1.79769313486232E+308 to -4.94065645851247E-324 or

4.94065645851247E- to 3241.79769313486232E+308

Currency 8 bytes -922,337,203,685,477.5808 to 922,337,203,685,477.5808

Decimal 12 bytes +/-79,228,162,514,264,337,593,543,950,335

This if no decimal.+/-

79,228,162,514,264,337,593,543,950,335

Page 10: Lesson 4 visual basic data

KINDS OF DATA TYPES2. Nonnumeric – usually consists of characters, date,

Boolean data or variant data types.Example:a. String – is a series of characters which may

range from zero or more characters. It may hold numeric characters but it is never used for calculations.

b. Date – used for dates.c. Boolean data – only holds two values, yes or no,

true or false.d. Variant – data that cam hold any kinds of data

except for fixed length strings.

Page 11: Lesson 4 visual basic data

KINDS OF DATA TYPES

Seven NonNumeric Data TypesType Storage Range

String as Fixed length 1 byte 1 to 65,400 characters

String as Variable 2 bytes 0 to 2 billion characters

Date 4 bytes January 1, 1000 to December 31, 9999

Boolean 4 bytes True or False

Object 8 bytes Any embedded objects

Variant (numeric) 8 bytes Any value as large as double

Variant(text) 12 bytes The same as variable length string

Page 12: Lesson 4 visual basic data

VARIABLESVariables are inserted as code statements. These are temporary named storage area inside the program’s memory that will hold data. Variable names are important in a program; they hold a value for as long as the user doesn’t change the value. Unlike with a control (txtname.text=“Visual Basic) which does not hold values for long. This means that variables are memory locations which are used to store values temporarily.

Page 13: Lesson 4 visual basic data

VARIABLE DeclarationsVariables declarations depend on how and where they are declared. Variables can be declared as explicit declaration or option implicit.Option Explicit Declaration - tells Visual Basic that the rest of the code in a module is to declare all variables before they are used.Option Implicit Declaration – easier way of declaring a variable however it is not advisable to use. This is a type where you don’t need to declare a variable as Visual Basic automatically assign a variable type.

Page 14: Lesson 4 visual basic data

EXPLICIT Declarations

It is advisable to declare all variables before they are used in a program. Using the DIM statement to declare variables by assigning them a name and a data type. Below is the format of the DIM statement in a variable declaration.

Dim Varname as Data TypeVarname is the name you assign to a variable and theData type is the type of data that the variable will hold.

Page 15: Lesson 4 visual basic data

EXPLICIT DeclarationsLike giving names in a control, variables also used prefixes in assigning names to them. Below are the variable name prefixes that describe variables data type.

Prefix Data Type Examplebln Boolean blnoptionbyt Byte Bytagecur Currency Curitrdte Date Dteinventorydbl Double Dbllongnumbersint Integer Intyearlevellng Long LngspeedObj Object ObjpresentationSng Single SngincomeStr String Strnamevnt variant vntnum

Page 16: Lesson 4 visual basic data
Page 17: Lesson 4 visual basic data

Transitional Page

Page 18: Lesson 4 visual basic data

Backdrops:- These are full sized backdrops, just scale them up!- Can be Copy-Pasted out of Templates for use anywhere!

www.animationfactory.com