VBscript Complete Reference Guide - Chapter 1

Share Embed Donate


Short Description

VBscript is a very light weight and user friendly language. It is currently running in industry as one of the prominent ...

Description

Comparing VBScript control structures to JavaScript control structures

http://www.apextgi.in

Data Types and Control Structures JavaScript

VBScript

1 if ( s == t ) 2 u = s + t; 3 else if ( s > t ) 4 u = r; 5 else 6 u = n;

1 2 3 4 5 6 7

If s = u = ElseIf u = Else u = End If

t Then s + t s > t Then r n

Comparing JavaScript’s if structure to VBScript’s If structure JavaScript

VBScript

1 switch ( x )  2 c!se 1" 3 !lert(#1#); 4  $re!%; 5 c!se 2" 6 !lert(#2#); 7  $re!%; & def!ult" ' !lert(##); 1 *

1 elect ,!se x 2 ,!se 1 3 ,!ll -s./0x(#1#) 4 ,!se 2 5 ,!ll -s./0x(#2#) 6 ,!se Else 7 ,!ll -s./0x(##) & End elect

Comparing JavaScript’s switch to switch to VBScript’s Select Case

Data Types and Control Structures JavaScript

VBScript

1  while ( ( x == 1 ) ) 2 ++x;

1 0 ntil x = 1 2 x = x + 1 3 00

Comparing JavaScript’s while  while to VBScript’s 0 ntil

JavaScript

VBScript

1 d0  2 ++x; 3 * while ( ( x == 1 ) );

1 0 2 x = x + 1 3 00 ntil x = 1

Comparing JavaScript’s d08while to VBScript’s 0 008ntil JavaScript VBScript 1 x = &; 2 f0r (  = 1;   x; ++ ) 3 x 8= 2;

1 x = & 2 90r  = 1 T0 x 3 x = x : 2 4  ext

Comparing JavaScript’s for  to  to VBScript’s For 

Data Types Types and a nd Cont rol an d Control Structures ◦









Select Case/End Select  Does not require break  type  type statement

VBScript structures without direct JavaScript equivalents:  Do Until/Loop  Do/Loop Until  Loop until condition becomes True Exit Do  mmediate e!it "rom Do hile/Loop# Do/Loop hile# Do Until/Loop or Do/Loop Until Exit !or  mmediate e!it "rom !or/"ext !or loop  $ptional Step %eyword to increment or decrement # $ %&Script ' !or y ( ' To ') Step ' * Call +sg&ox, -y -y ( -  y  0 "ext

%&Script !unctions 

&rede"ined "unctions ◦

Variant "unctions 

1sE2pty 



)ath "unctions 



Cos# Sin# etc* 

+a%e arguments in radians



radians , degrees

 -./01

1nput&ox 



'eturns True i" variant not initiali(ed

Displays dialog in which user can input data

+sg&ox 

Displays message dialog



VBScript "unctions o"ten ta%e optional arguments



2ormatting "unctions 

!or2atCurrency# !or2atDateTi2e# etc*

%&Script !unctions ◦



2unctions "or getting in"o about scripting engine  ScriptEngine  'eturns 33script4# 3%&Script4 or 3%&44  ScriptEngine&uild%ersion  'eturns current build version5 D number "or current release  ScriptEngine+a5or%ersion  'eturns ma6or version number "or script engine  ScriptEngine+inor%ersion  'eturns minor release number 

Line continuation character  7nderscore character# 6  Statements cannot e!tend beyond current line without character  ◦



%&Script Exa2ple 7rogra2s 

8lways place VBScript code inside 9+)L comments ◦



Script variables ◦



&revent code "rom being displayed as te!t in browsers that do not understand VBScript Variables declared outside o" procedures

Const %eyword ◦

Create constants

%&Script Exa2ple 7rogra2s 

Comments ◦

Single quote 8;



line continuation character# character# required i" statement e!tends beyond a line 

7se as many as necessary

%&Script Exa2ple 7rogra2s 

Calling "unctions ◦

" "unction call has arguments arguments in parentheses# use %eyword Call 

" "unction assigns a variable# Call not needed a ( 4bs, < 





" parentheses not used# %eyword Call not needed

2unction +sg&ox ◦

Displays message dialog

+sg&ox -%&Script is =un>-  -9esults-9 esults◦



Displays -%&Script is =un>-  with -9esults- in the title  bar  $ptional argument to customi(e buttons and icon ignored

   Tr!nsiti0n!l88E#>  Tr!nsiti0n!l88E# >   BB9i.D 22D15" !dditi0nDhtl BB>  3  BB9i.D  AE>  5  AE>   TITE>  6  TITE>    7  ,FI@T GGE = #/crit# &  ,FI@T #/crit#>  >   BB '  BB 1    AF>  3  I@T -E = #cddd# T?@E = #/TT  T0t!l#>  32  89   89  33  8/   8/  34  8AT->   8AT-> 

1.1Set 1.1 Set language language to VBScript 1.2
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF