• No results found

Vb Script

N/A
N/A
Protected

Academic year: 2021

Share "Vb Script"

Copied!
6
0
0

Loading.... (view fulltext now)

Full text

(1)

VBSCRIPT VARIABLES AND DATATYPES VBSCRIPT VARIABLES AND DATATYPES

What Is a Variable? What Is a Variable?

A variable is a convenient placeholder that refers to a computer memory location A variable is a convenient placeholder that refers to a computer memory location where you can store program information that may change

where you can store program information that may change during executionduring execution

Declaring Variables

Declaring Variables

We declare variables explicitly in our script using

We declare variables explicitly in our script using thethe DimDim statement, the statement, the PublicPublic

statement, and the

statement, and the PrivatePrivate statement. We declare multiple variables by separating statement. We declare multiple variables by separating each variable name with a comma.

each variable name with a comma. For example:

For example: Dim TDim Topop, ottom, , ottom, !eft, "ight!eft, "ight

We can also declare a variable implicitly by simply using its name in our script. We can also declare a variable implicitly by simply using its name in our script. ecause we may misspell the variable name in one or more places, causing ecause we may misspell the variable name in one or more places, causing unexpected results During execution. For that reason,

unexpected results During execution. For that reason, thethe Option ExplicitOption Explicit statement statement is available to re#uire explicit declaration of

is available to re#uire explicit declaration of all variables. The $ption %xplicitall variables. The $ption %xplicit statement should be the first statement in the script.

statement should be the first statement in the script.

Option explicit: Option explicit:

When We use the $ption %xplicit statement, you must explicitly declare all variables When We use the $ption %xplicit statement, you must explicitly declare all variables using the Dim, &rivate, &ublic, or "eDim statements. 'f

using the Dim, &rivate, &ublic, or "eDim statements. 'f we attempt to use anwe attempt to use an undeclared variable name, causing an error occurs.

undeclared variable name, causing an error occurs. (aming "estrictions

(aming "estrictions )aria

)ariable names follow the ble names follow the standard rules for naming anything in )*cript. Astandard rules for naming anything in )*cript. A variable name:

variable name:

• +ust begin with an alphabetic character.+ust begin with an alphabetic character. •

• annot contain an eannot contain an embedded period.mbedded period. •

• +ust not exceed - characters.+ust not exceed - characters. •

• +ust be uni#ue in the scope in which it is declared.+ust be uni#ue in the scope in which it is declared.

Assigning )alues to )ariables Assigning )alues to )ariables

)alues are assigned to variables creating an expression as

)alues are assigned to variables creating an expression as follows: the variable isfollows: the variable is on the left

on the left side of the expression and the value you want to assign to the variable isside of the expression and the value you want to assign to the variable is on the right.

on the right. For

(2)

DATATYPES

What Are VBScript Data Types?

VBScript has nly ne !ata type calle! a Variant" A Variant is a special #in! $ !ata type that can cntain !i$$erent #in!s $ in$r%atin& !epen!ing n h' it(s )se!. ecause )ariant is the only data type in )*cript, it1s also the data type returned by all functions in )*cript.

At its simplest, a )ariant can contain either numeric or string information. A )ariant behaves as a number when you use it in a numeric context and as a string when you use it in a string context. That is, if you1re wor2ing with data that loo2s li2e numbers, )*cript assumes that it is numbers and does the thing that is most appropriate for numbers. *imilarly, if you1re wor2ing with data that can only be string data, )*cript treats it as string data. $f course, you can always ma2e numbers behave as strings by enclosing them in #uotation mar2s 34 45.

Variant S)btypes

The $ll'ing table sh's the s)btypes $ !ata that a Variant can cntain"

*ubtype Description

E%pty Variant is )ninitiali*e!" Val)e is + $r n)%eric ,ariables r a *er-length string .//0 $r string ,ariables"

N)ll Variant intentinally cntains n ,ali! !ata" Blean Cntains either Tr)e r 1alse"

Byte Cntains integer in the range + t 233"

Integer Cntains integer in the range -42&567 t 42&565" C)rrenc

y

-822&445&2+4&673&955"37+7 t 822&445&2+4&673&955"37+5"

Lng Cntains integer in the range -2&:95&974&697 t 2&:95&974&695"

Single Cntains a single-precisin& $lating-pint n)%ber in the range -4"9+2724E47 t -:"9+:287E-93 $r

(3)

psiti,e ,al)es"

D)ble Cntains a !)ble-precisin& $lating-pint n)%ber in the range -:"585684:4976242E4+7 t

-9"89+6369379:295E-429 $r negati,e ,al)es;

9"89+6369379:295E-429 t :"585684:4976242E4+7 $r psiti,e ,al)es"

Date .Ti%e0

Cntains a n)%ber that represents a !ate bet'een <an)ary :& :++ t Dece%ber 4:& 8888"

String Cntains a ,ariable-length string that can be )p t appr=i%ately 2 billin characters in length"

>bect Cntains an bect"

Errr Cntains an errr n)%ber"

Operator Precedence

When se,eral peratins cc)r in an e=pressin& each part is e,al)ate! an! resl,e! in a pre!eter%ine! r!er calle! peratr prece!ence . 6ou can use parentheses to override the order of precedence and force some parts of an

expression to be evaluated before others. $perations within parentheses are always performed before those outside. Within parentheses, however, standard operator precedence is maintained.

When e=pressins cntain peratrs $r% %re than ne categry& arith%etic peratrs are e,al)ate! $irst& c%parisn peratrs are e,al)ate! ne=t& an! lgical peratrs are e,al)ate! last" C%parisn

peratrs all ha,e e@)al prece!ence; that is& they are e,al)ate! in the le$t-t-right r!er in 'hich they appear" Arith%etic an! lgical peratrs ar e e,al)ate! in the $ll'ing r!er $ prece!ence"

Arithmetic

Description Symbol

Exponentiation

^

Unary negation

-Multiplication

*

Division

/

(4)

Integer division

\

Modulus arithmetic

Mod

Addition

+

Subtraction

-String concatenation

&

omparison

Description Symbol

E!uality

"

Ine!uality

#$

%ess than

#

reater than

$

%ess than or e!ual to

#"

reater than or e!ual to

$"

'b(ect e!uivalence

Is

%ogical

Description Symbol

Logical negation

 Not

Logical conjunction

And

Logical disjunction

Or 

Logical exclusion

Xor 

Logical equivalence

Eqv

Logical imlication

!m

When multiplication and division occur together in an expression, each operation is evaluated as it occurs from left to right. !i2ewise, when addition and subtraction

(5)

occur together in an expression, each operation is evaluated in order of appearance from left to right.

The string concatenation 375 operator is not an arithmetic operator, but in precedence it falls after all arithmetic operators and before all comparison

operators. The 's operator is an ob8ect reference comparison operator. 't does not compare ob8ects or their values9 it chec2s only to determine if two ob8ect

references refer to the same ob8ect.

The lgic $ >R is that i$ at least ne $ the inp)ts are Tr)e& the )tp)t is tr)e;

Tr)e >R Tr)e  Tr)e Tr)e >R 1alse  Tr)e 1alse >R Tr)e  Tr)e 1alse >R 1alse  1alse

>R nly ret)rns Tr)e i$ ne an! nly ne $ the inp)ts is Tr)e" Tr)e r Tr)e  1alse

Tr)e r 1alse  Tr)e 1alse r Tr)e  Tr)e 1alse r 1alse  1alse

I%p ret)rns $alse i$ $irst ne is tr)e an! secn! ne $alse e=cept this it ret)rns tr)e"

Tr)e i%p Tr)e  Tr)e Tr)e i%p 1alse  1alse 1alse i%p Tr)e  Tr)e 1alse i%p 1alse  Tr)e

(6)

References

Related documents

In summary and taking into account the resonance characteristics of the ACUREX plant, the main contribution of this paper, is to improve a gain schedul- ing (GS) predictive

Applications of Fourier transform ion cyclotron resonance (FT-ICR) and orbitrap based high resolution mass spectrometry in metabolomics and lipidomics. LC–MS-based holistic metabolic

Such a collegiate cul- ture, like honors cultures everywhere, is best achieved by open and trusting relationships of the students with each other and the instructor, discussions

At a time when claims are made that ‘there’s an app for that’ (Apple), this original study explored heritage language families ’ relationship with games-based technology,

The countries of the region, through their Ministries of Agriculture in coordination with national and regional plant and animal health organizations and the agricultural industry

Racks, Cages and Suites – flexible solutions for renting data centre space from a single rack to dedicated secure suites &amp; cages, supported by highly efficient cooling,

Factors, Practices, and Policies Influencing Students’ Upward Transfer to.. Baccalaureate-Degree Programs and

General Fund fringe benefits are projected to end the fiscal year $2.2 million, or 0.7 percent, under budget, which is a slight increase from the Mid-Year