2. History
VBScript began as part of the Microsoft Windows Script
Technologies, launched in 1996
in the fall of 1996, Internet Explorer is made with features that
include VBScript.
In version 5.0, the functionality of VBScript was increased with
new features such as: regular expressions; classes; the With
statement;[the Eval, Execute, and ExecuteGlobal functions to
evaluate and execute script commands built during the
execution of another script; a function-pointer system via
GetRef, and Distributed COM (DCOM) support.
Not longer under development, MS recommends to use
PowerShell
3. In general
Programming language
Very limited OOP support
Dynamically typed
Interpreted
But yet very powerful (for small tasks) because of
MS’ component model
Must be executed inside a host (WSH, Internet
Explorer, IIS, MS Script Control)
5. Variables
Dim Top, Bottom, Left, Right
Naming restrictions:
– Must begin with an alphabetic character.
– Cannot contain an embedded period.
– Must not exceed 255 characters.
– Must be unique in the scope in which it is declared.
Scope and Lifetime of variables
– Procedural
– Class
– All-Script
Set value: CutoffDate = #06/18/2008 01:05:09#
Constants marked with Const:
– Const MyString = "This is my string.“
–
Const MyAge = 49
7. Statements
If...Then…Else
If myDate < Now Then myDate = Now
Select Case
Loops:
– Do…Loop
– While…Wend
– For…Next
– For Each…Next:
8. Sub and Function procedures
Sub can’t return result
Function can return value
Can have zero or more arguments
To call: use call+() or do not use ()
ByRef, ByVal
9. What’s next?
Collections: Dictionaries
XML (MSXML)
COM usage: Internet Explorer, MS Office,
FileSystemObject, etc., etc.
Classes
Error Handling