Programming Languages
A Dave Hillman Project

[Home] [Contact Me] [Site Map] [Search] [References]

VBScript

 

[Up]

[Language Basics]
[C Language]
[C++]
[C#]
[Java]
[JavaScript]
[Visual Basic 6.0]
[VBScript]
[VB.Net]
[.Net Technology]

 

 

Introduction

bulletUsed for:
  1. Client-based applications, similar to JavaScript in terms of operation.  Only runs in Microsoft Internet Explorer.
  2. Server-based applications, typically in conjunction with tools such as ASP (Active Server Pages) and ADO (ActiveX Data Objects.
bulletAlso called the Microsoft Visual Basic Scripting Edition, a subset of the Microsoft Visual Basic programming language
bulletIt is a fast, portable, lightweight interpreter for use in Web browsers and other applications that use Microsoft ActiveX Controls.

Language Fundamentals

Much of VBScript is based on Visual Basic with minor exceptions based on the specifics of various environments (e.g., web browsers).

Data Types

bulletVBScript has only one data type called a Variant
bulletIt is a a special kind of data type that can contain different kinds of information, depending on how it is used. 
bulletBecause the Variant is the only data type in VBScript, it is also the data type returned by all functions in VBScript.
bulletIt can contain either numeric or string information
bulletIt behaves as a number when you use it in a numeric context and as a string when you use it in a string context.
bulletThe Dim statement is used to declare variables.
bulletVariable names follow the standard rules for naming anything in VBScript. A variable name:
bulletMust begin with an alphabetic character.
bulletCannot contain an embedded period.
bulletMust not exceed 255 characters.
bulletMust be unique in the scope in which it is declared.

Operators

Arithmetic

Exponentiation  ^
Unary negation  -
Multiplication  *
Division  /
Integer division  \
Modulus arithmetic  Mod
Addition  +
Subtraction  -
String concatenation  &
 

Comparison

Equality  =
Inequality  <>
Less than  <
Greater than  >
Less than or equal to  <=
Greater than or equal to  >=
Object equivalence  Is
 

Logical

Logical negation  Not
Logical conjunction  And
Logical disjunction  Or
Logical exclusion  Xor
Logical equivalence  Eqv
Logical implication  Imp

Control Statements

Essentially VBScript uses the same control statements as Visual Basic

bulletIf...Then...Else
bulletDo...Loop
bulletFor...Next
bulletFor Each...Next
bulletSelect Case
bulletWhile...Wend
bulletWith

Program Features

Category Keywords
Array handling Array 
Dim, Private, Public, 
ReDim 
IsArray 
Erase 
LBound, UBound
Constants/Literals Empty
Nothing
Null
True, False
Conversions Abs
Asc, AscB, AscW
Chr, ChrB, ChrW
CBool, CByte
CCur, CDate
CDbl, CInt
CLng, CSng, CStr
DateSerial, DateValue
Hex, Oct
Fix, Int
Sgn
TimeSerial, TimeValue
Dates/Times Date, Time
DateAdd, DateDiff, DatePart
DateSerial, DateValue
Day, Month, MonthName
Weekday, WeekdayName, Year
Hour, Minute, Second
Now
TimeSerial, TimeValue
Declarations Class
Const
Dim, Private, Public, ReDim
Function, Sub
Property Get, Property Let, Property Set
Error Handling On Error
Err
Expressions Eval
Execute
RegExp
Replace
Test
Formatting Strings FormatCurrency
FormatDateTime
FormatNumber
FormatPercent
Input/Output InputBox
LoadPicture
MsgBox
Literals Empty
False
Nothing
Null
True
Math Atn, Cos, Sin, Tan
Exp, Log, Sqr
Randomize, Rnd
Miscellaneous Eval Function
Execute Statement
RGB Function
Objects CreateObject
Err Object
GetObject
RegExp
Options Option Explicit
Procedures Call
Function, Sub
Property Get, Property Let, Property Set
Script Engine ID ScriptEngine
ScriptEngineBuildVersion
ScriptEngineMajorVersion
ScriptEngineMinorVersion
Strings Asc, AscB, AscW
Chr, ChrB, ChrW
Filter, InStr, InStrB
InStrRev
Join
Len, LenB
LCase, UCase
Left, LeftB
Mid, MidB
Right, RightB
Replace
Space
Split
StrComp
String
StrReverse
LTrim, RTrim, Trim
Variants IsArray
IsDate
IsEmpty
IsNull
IsNumeric
IsObject
TypeName
VarType

Input/Output

bulletVBScript, within the web browser environment, is dependent upon the browser (via HTML) for user input/output.
bulletVBScript, within the server environment, has input/output access via Active Server Pages (ASP) objects, i.e., Response and Request objects.
bulletFile I/O is restricted in web browsers due to security considerations.  However, file access can be accomplished via system file objects (web server only).
bulletVBScript does not have database access capability in the browser; it has access to databases via ASP and related database object technologies (i.e., ActiveX Data Objects, ADO).


Resources

bullet http://msdn.microsoft.com/scripting/default.htm
bullethttp://devguru.com - DevGuru is a very good resource.

 

 

[Home] [Language Basics] [C Language] [C++] [C#] [Java] [JavaScript] [Visual Basic 6.0] [VBScript] [VB.Net] [.Net Technology]

Copyright © 2003-2005 by Dave Hillman