• No results found

B VBScript03

N/A
N/A
Protected

Academic year: 2021

Share "B VBScript03"

Copied!
18
0
0

Loading.... (view fulltext now)

Full text

(1)

VBScript

VBScript

Session 3

(2)

What We learn Last seasson?

What We learn Last seasson?

How to declare arrays.

How to declare arrays.

Working with one dimensional a

Working with one dimensional a

multi-dimensional arrays.

dimensional arrays.

Working with Dynamic arrays.

Working with Dynamic arrays.

Arrays utilities (Array,UBound, LBound)

Arrays utilities (Array,UBound, LBound)

(3)

Subjets for Session 3

Subjets for Session 3

Const Statement.

Const Statement.

Operators.

Operators.

Arithmetic.

Arithmetic.

Comparision.

Comparision.

Logical.

Logical.

(4)

Constants

Constants

Const Statement

Const Statement

[[Public

Public

|| Private

Private

]] Const

Const

constname

constname =

= expression

expression

A constant is a meaningful name that takes the place of a

A constant is a meaningful name that takes the place of a

number or string and never changes.

number or string and never changes.

VBScript defines a number of intrinsic constants.

VBScript defines a number of intrinsic constants.

You create user-defined constants in VBScript using the

You create user-defined constants in VBScript using the

Const

(5)

Constants

Constants

Const Statement

Const Statement

You may want to adopt a naming scheme to differentiate constants

You may want to adopt a naming scheme to differentiate constants

from variables.

from variables.

This will prevent you from trying

This will prevent you from trying to reassign constant values while

to reassign constant values while

your script is running.

your script is running.

For example, you might want to use a

For example, you might want to use a "vb" or "con" prefix on your

"vb" or "con" prefix on your

constant names, or you might name your constants in all capital

constant names, or you might name your constants in all capital

letters:

letters:

conMaxValue, vbMyValue, MY_VALUE

conMaxValue, vbMyValue, MY_VALUE

Differentiating constants from variables eliminates

Differentiating constants from variables eliminates confusion as

confusion as

you develop more complex scripts.

you develop more complex scripts.

Const

Const

MyString = "This is my string."

MyString = "This is my string."

Const

Const

MyAge = 19

MyAge = 19

Const

(6)

Dani Vainstein

Dani Vainstein 66

VBScript Operators

VBScript Operators

VBScript has a full range of operators, including

VBScript has a full range of operators, including

arithmetic operators, comparison operators,

arithmetic operators, comparison operators,

concatenation operators, and logical operators.

concatenation operators, and logical operators.

When several operations occur in an expression, each

When several operations occur in an expression, each

part is evaluated and resolved in a predetermined order

part is evaluated and resolved in a predetermined order

called operator precedence.

called operator precedence.

You can use parentheses to override the order of 

You can use parentheses to override the order of 

precedence and force some parts of an expression to be

precedence and force some parts of an expression to be

evaluated before others.

evaluated before others.

Operations within parentheses are always

Operations within parentheses are always

performed before those outside

(7)

VBScript Operators

VBScript Operators

When expressions contain operators from more than

When expressions contain operators from more than

one category, arithmetic operators are evaluated first,

one category, arithmetic operators are evaluated first,

comparison operators are evaluated next, and logical

comparison operators are evaluated next, and logical

operators are evaluated last.

operators are evaluated last.

Comparison operators all have equal precedence; that

Comparison operators all have equal precedence; that

is, they are evaluated in the l

is, they are evaluated in the left-to-right order in

eft-to-right order in

which they appear.

which they appear.

Arithmetic and logical operators are evaluated in the

Arithmetic and logical operators are evaluated in the

following order of precedence.

(8)

VBScript Operators

VBScript Operators

Arithmetic Operators

Arithmetic Operators

Exponentation operator

Exponentation operator

Symbol Symbol : ^: ^ Description

Description: Raises a number to the power of an : Raises a number to the power of an exponent.exponent. Syntax

Syntax: result: result == numbernumber^^exponentexponent Note

Note: If either: If either number number  oror exponent exponent  is a Null expression,is a Null expression, result result  is alsois also NullNull..

Substraction operator

Substraction operator

Symbol

Symbol : -: -Description

Description: Finds the : Finds the difference between two numbers or indicates thedifference between two numbers or indicates the negative value of a

negative value of a numeric expression.numeric expression. Syntax

Syntax: result: result == number1-number2 : -numbernumber1-number2 : -number Note

Note: If one : If one or both expressions are Null expressions,or both expressions are Null expressions, result result isis NullNull. If an. If an expression is

(9)

VBScript Operators

VBScript Operators

Arithmetic Operators

Arithmetic Operators

Multiplication

Multiplication operator

operator

Symbol

Symbol : *: * Description

Description: Multiplies two numbers.: Multiplies two numbers. Syntax

Syntax: result: result == number1*number2number1*number2 If one or both

If one or both expressions are Null expressions,expressions are Null expressions, result result  isis NullNull. If an. If an expression is

expression is EmptyEmpty, it is treated as if it , it is treated as if it were 0.were 0.

Division operator

Division operator

Symbol

Symbol : /: / Description

Description: Divides two numbers and returns : Divides two numbers and returns a floating-point result.a floating-point result. Syntax

Syntax: result: result == number1/number2number1/number2 Note

Note: If one : If one or both expressions are Null expressions,or both expressions are Null expressions, result result isis NullNull. If an. If an expression is

(10)

VBScript Operators

VBScript Operators

Arithmetic Operators

Arithmetic Operators

Integer Division operator

Integer Division operator

Symbol

Symbol

: \ 

: \ 

Description

Description

: Divides two numbers and returns an integer result.

: Divides two numbers and returns an integer result.

Syntax

Syntax

: result

: result =

= number1\number2

number1\number2

Note

Note

: Before division is performed, numeric expressions are

: Before division is

performed, numeric expressions are

rounded to

rounded to Byte

Byte

,, Integer

Integer

, or

, or Long

Long

subtype expressions.

subtype expressions.

If any expression is Null,

If any expression is Null, result 

result 

is also

is also Null

Null

. Any expression that is

. Any expression that is

Empty is treated as 0.

(11)

VBScript Operators

VBScript Operators

Arithmetic Operators

Arithmetic Operators

Modulus arithmetic operator

Modulus arithmetic operator

Symbol

Symbol

: Mod

: Mod

Description

Description

: Divides two numbers and returns only the

: Divides two numbers and returns only the

remainder.

remainder.

Syntax

Syntax

: result

: result =

= number1 Mod number2

number1 Mod number2

Notes

Notes

: The modulus, or remainder, operator divides

: The modulus, or remainder, operator divides number1

number1 by

by

number2

number2

(rounding floating-point numbers to integers) and returns

(rounding floating-point numbers to integers) and returns

only the remainder as

only the remainder as result 

result 

..

If any expression is Null,

If any expression is Null, result 

result 

is also

is also Null

Null

. Any expression that is

. Any expression that is

Empty

(12)

VBScript Operators

VBScript Operators

Arithmetic Operators

Arithmetic Operators

Addition operator

Addition operator

Symbol

Symbol

: +

: +

Description

Description

: Sums two numbers.

: Sums two numbers.

Syntax

Syntax

: result

: result =

= number1+number2

number1+number2

Note

Note

: Although you can also use the

: Although you can also use the +

+ operator to concatenate

operator to concatenate

two character strings, you should use the

two character strings, you should use the & 

operator for

operator for

concatenation to eliminate ambiguity and

concatenation to eliminate ambiguity and provide self-documenting

provide self-documenting

code.

(13)

VBScript Operators

VBScript Operators

Arithmetic Operators

Arithmetic Operators

Concatenation

Concatenation operator

operator

Symbol

Symbol : & : &  Description

Description: Forces string concatenation of two expressions.: Forces string concatenation of two expressions. Syntax

Syntax: result: result == expression1 & expression2expression1 & expression2 Notes

Notes: Whenever an: Whenever an expressionexpression is not a string, it is converted to ais not a string, it is converted to a StringString subtype.

subtype.

If both expressions are Null,

If both expressions are Null, result result  is alsois also NullNull.. However, if only one

However, if only one expressionexpression isis NullNull, that expression is treated as a zero-, that expression is treated as a zero-length string ("") when concatenated with the other expression.

length string ("") when concatenated with the other expression. Any expression that is Empty is also treated

(14)

VBScript Operators

VBScript Operators

Comparision Operators

Comparision Operators

Equality and Inequality operators

Equality and Inequality operators

Symbol

Symbol : =, <, <=, >, >=, <>: =, <, <=, >, >=, <> Description

Description: Used to : Used to compare expressions.compare expressions. Syntax

Syntax: result: result == expression1 comparisonoperator expression1 comparisonoperator expression2expression2 Note

Note: When comparing two expressions, you may not : When comparing two expressions, you may not be able to easilybe able to easily determine whether the expressions are being compared as numbers or determine whether the expressions are being compared as numbers or asas strings. strings.

In

In operator

operator

Symbol Symbol : In: In Description

Description: Compares two object reference variables.: Compares two object reference variables. Syntax

Syntax: result: result == object1object1 IsIs object2object2 Note

Note: If : If object1object1 andand object2object2 both refer to the same object,both refer to the same object, result result isis TrueTrue;; if they do not,

(15)

VBScript Operators

VBScript Operators

Logical Operators

Logical Operators

Logical Conjuction (And)

Logical Conjuction (And) operator

operator

Symbol

Symbol

: Not

: Not

Description

Description

: Performs logical negation on an

: Performs logical negation on an expression.

expression.

Syntax

Syntax

: result

: result =

= Not

Not

expression

expression

N Nuullll NNuullll F Faallssee TTrruuee T Trruuee FFaallssee If

(16)

VBScript Operators

VBScript Operators

Logical Operators

Logical Operators

Logical Conjuction (And)

Logical Conjuction (And) operator

operator

Symbol

Symbol

: And

: And

Description

Description

: Performs a logical

: Performs a logical conjunction on two expressions.

conjunction on two expressions.

Syntax

Syntax

: result

: result =

= expression1

expression1 And

And

expression2

expression2

Null Null Null Null Null Null False False False False Null Null Null Null True True Null Null False False Null Null False False False False False False False False False False True True False False Null Null Null Null True True False False False False True True True True True True True True The

The result result isis

And expression2 is

And expression2 is

If expression1 is

(17)

VBScript Operators

VBScript Operators

Logical Operators

Logical Operators

Logical disjuction (Or) operator

Logical disjuction (Or) operator

Symbol

Symbol

: Or

: Or

Description

Description

: Performs a logical disjunction on two expressions.

: Performs a logical disjunction on two expressions.

Syntax

Syntax

: result

: result =

= expression1

expression1 Or

Or

expression2

expression2

Null Null Null Null Null Null Null Null False False Null Null True True True True Null Null Null Null Null Null False False False False False False False False True True True True False False True True Null Null True True True True False False True True True True True True True True The

The result result isis

And expression2 is

And expression2 is

If expression1 is

(18)

VBScript Operators

VBScript Operators

Logical Operators

Logical Operators

Logical Exclusion

Logical Exclusion (Xor)

(Xor) operator

operator

Symbol

Symbol

: Xor

: Xor

Description

Description

: Performs a logical exclusion on two expressions.

: Performs a logical exclusion on two expressions.

Syntax

Syntax

: result

: result =

= expression1

expression1 Xor

Xor

expression2

expression2

False False False False False False True True True True False False True True False False True True False False True True True True The

The result result isis And expression2 is And expression2 is If expression1 If expression1 is is

References

Related documents

The number of machines, their probabilities in the population, numbers of machine states, state transition functions and action probabilities (by machine state) are all variable:

Although similar in their taxonomic distribution of metagenomic reads, Arctic and Antarctic viromes differed at the fine-grain genetic level, indicating that they are dominated

The present study showed that one-day simulation training in post- partum hemorrhage prevention and management increased knowledge and con fidence among skilled and semiskilled

processed by pressing the unsharp-masking filter and top-hat filter. The resultant image is on the axes 3. The contrast stretching of the top-hat filtered image is performed using

• The arithmetic operators +, -, *, /, and % perform mathematical operations on variables and values. • In the expression x + y, + is the operator, while x and y are

why there was no substantive effect on the data. Given the choices, there was no basis for someone who worked in a place where smoking was not allowed to get into

All members can everything that you like your face and one direction more than this audio file formats on your desired option and music entertainment!. As all waiting for free

Results: A distinctive N400 component which was modulated by emotional content of vocal stimulus was observed in children over parietal and occipital scalp regions—amplitudes