VBScript: Working Description
An overview of Microsoft® Visual Basic® Scripting EditionThe VBScript Team
March 1996
Disclaimer: This document is an early release of the final specification. It is meant to specify and accompany software that is still in development. Some of the information in this documentation may be inaccurate or may not be an accurate representation of the functionality of the final specification or software. Microsoft assumes no responsibility for any damages that might occur either directly or indirectly from these inaccuracies. Microsoft may have trademarks, copyrights, patents or pending patent applications, or other intellectual property rights covering subject matter in this document. The furnishing of this document does not give you a license to these trademarks, copyrights, patents, or other intellectual property rights. Contents:
- Product Line Overview
- Language Description
- Run-Time Description
- Preliminary Licensing Terms
- More Questions and Answers
VBScript is an upwardly compatible subset of the popular Microsoft Visual Basic® programming system. Its source implementation is licensed at no charge to interested software developers for inclusion with their products. Microsoft will provide binary implementations of VBScript for the 32-bit Windows® API, the 16-bit Windows API, and the Macintosh® in the first half of 1996. VBScript is tightly integrated into World Wide Web browsers, and is designed to work with OLE controls, applets, and other objects embedded in World Wide Web (HTML) documents; however, VBScript can also be used as a general automation language with other applications.
1. Visual Basic Product Line Overview
Microsoft has designed Visual Basic as a scalable development tool for Internet and Enterprise applications. There are a number of places where Visual Basic developers create value, including creating "active" HTML documents, customizing productivity products, and building client/server business applications.
To support these scenarios, Microsoft provides Visual Basic in three upwardly compatible packages:
VBScript
This lightweight subset of Visual Basic will be licensed to industry companies and corporations free of charge. Microsoft will provide Visual Basic on Windows and Macintosh platforms, and is working with third parties to provide Unix® versions for Sun®, HP®, Digital, and IBM® platforms. VBScript is packaged as a compiler and associated run-time libraries. At this point, Microsoft does not provide integrated development support tools (editing, layout, debugging, and so on) for VBScript. Microsoft anticipates that this product will be available to licensees and other interested parties in the first half of 1996.
Visual Basic for Applications
Visual Basic for Applications is Microsoft's strategic application scripting language. It is highly extensible using OLE Automation and other OLE-based mechanisms. It includes a complete development environment, including integrated editor and debugging support. Currently, Visual Basic for Applications is found only in the Microsoft Office family of products on Windows and the Macintosh.
Visual Basic 4.0
The Visual Basic packaged development tool product comes in three editions: the Standard Edition for students and hobbyists, the Professional Edition for individual developers, and the Enterprise Edition for developers working in teams or in corporate settings. Visual Basic 4.0 provides a superset of the language and tool functionality in Visual Basic for Applications. Key features include client/server data access, distributed computing (for example, three-tier) support, and team source code control support. Currently, Visual Basic 4.0 is available only for Windows.
2. VBScript Language Description
Scenarios
HTML scripting
The MS-FTD Internet site enables users to order flowers. With VBScript support, MS-FTD makes this process easier for their customers and for themselves. For example, date validation can be done on the client, thus reducing the use of network bandwidth, since there is no need to make a trip to the server and back to check that the date is valid. This makes things easier for the user and easier for MS-FTD.
OLE scripting manager
VBScript is a component that is used by a host (such as an Internet browser or other application). Other vendors will certainly be interested in providing similar components. A host should not have to write special integration code to host multiple scripting components, so Microsoft plans to work with various Internet consortia to define an OLE scripting standard that allows scripting engines to be plug-compatible. This will be part of the Microsoft Internet Explorer, which will be made available to third parties at no cost.
We envision a world in which a host interacts with an "OLE scripting manager" using some interface, say IScriptManager. The scripting manager enables a host to compile scripts, obtain and call entry points, and manage the namespace available to the developer. With it, language vendors will be able to author pluggable language run times that enable Internet scripting. We will be providing run-time support for VBScript and Visual Basic.
Language description
This section briefly describes differences between VBScript and Visual Basic for Applications. The intent is to give the reader an idea of what the language is like, and provide enough information for getting started. A later document will describe the VBScript language more rigorously.
VBScript is a strict subset of Visual Basic for Applications. The best source of information on language syntax and semantics for Visual Basic for Applications is the Language Reference that comes with Visual Basic 4.0.
The VBScript language
Category Feature Arrays Declaration (Dim, Static, etc.)
LBound, UBound
ReDim, EraseAssignment =
Let
SetComments Using REM and ' Control flow Do...Loop
For...Next, For Each...Next
While...Wend
If...Then...ElseError trapping On Error Resume Next
Err objectLiterals Empty
Nothing
Null
True, False
User-defined literals:
-- 123.456; "Foo", etc.Miscellaneous Line continuation character (_)
Line separation character (:)Nonconforming identifiers o.[My long method name] Operators Arithmetic:
-- +, -, *, /, \, ^, Mod
-- Negation (-)
-- String concatenation (&)
Comparison:
-- =, < >,, <,, >,, < =, > =, Is
Logical:
-- Not
-- And, Or, Xor
-- Eqv, Imp
Options Option Explicit Procedures Declaring procedures:
-- Function
-- Sub
Calling procedures:
-- Call
Exiting procedures:
-- Exit Function
-- Exit Sub
Parameters for procedures:
-- ByVal, ByRef.Variables Procedure-level:
-- Dim
-- Static
Module-level:
-- Private, DimVisual Basic for Applications language features that are not in VBScript
Category Feature Arrays Option Base
Declaring arrays with LBound < > 0Calling DLLs Declare Collection access using ! MyCollection! Foo Conditional compilation #Const
#If...Then...#Else...#End IfControl flow DoEvents
GoSub...Return
GoTo
Line numbers and labels
On Error...GoTo
Select CaseData types Boolean
Byte
Currency
Date
Double
Integer
Long
Object
Single
String
Type suffixes (%, $, !, etc.)
User-defined classes (no Me)Debugging Debug.Print
End
StopError trapping Erl, Error, Error$
On Error...Resume
Resume, Resume NextFile I/O (Lots) Graphics Cls, Circle, Line, Point, PSet, Scale
Print, Spc, TabLiterals User-defined literals:
-- Based real numbers, such as 1.2345E+100
-- Dates, such as #4/7/69#
-- Trailing type characters, e.g., &hFF&
Named arguments Use of named arguments in calling members, e.g., Call Foo (bar:= 4) Operators Like Options DefType
Option Base
Option Compare
Option Private ModuleProcedures Declaring procedures:
-- Property Get/Let/Set
-- Specifying Public/Private
Exiting procedures:
-- Exit Property
Parameters for procedures:
-- ParamArray
-- OptionalStrings Fixed length strings
Mid, LSet, RSet statementsStructs Type...End Type
LSet, RSetUsing classes Dim x As New TypeName
Set x = New TypeName
If TypeOf x Is TypeName
With...End WithVariables and constants Data types:
-- Currency type
-- CCur
Module-level:
-- Const
-- Private, Dim
-- Public, Global
Procedure-level:
-- Const3. Run-Time Description
This section briefly describes differences between the VBScript and Visual Basic for Applications run times. The intent is to give the reader an idea of what features the VBScript run time will have. A later document will describe the VBScript run time more rigorously.
The VBScript run time is a subset of the Visual Basic for Applications run time. The best source of information regarding run-time functionality is the Language Reference that comes with Visual Basic 4.0.
The VBScript run time
Category Feature Arrays Array function Conversion Abs
Asc, Chr
CBool, CByte
CDate, CDbl, CInt
CLng, CSng, CStr
CVErr
DateSerial, DateValue
Fix, Int, Sgn
Hex, OctDates Date function, Time function
Day, Month, Weekday, Year
Hour, Minute, Second
Now
TimeSerial, TimeValueMath Atn, Cos, Sin, Tan
Exp, Log, Sqr
Randomize, RndObject CreateObject Strings Asc, AscB, AscW
Chr, ChrB, ChrW
Instr, InStrB
Len, LenB
LCase, UCase
Left, Right
LeftB, MidB, RightB
Mid function
Space(number)
StrComp
String(number, character)
Trim, LTrim, RTrimUI InputBox
MsgBoxVariant support IsArray
IsDate
IsEmpty
IsError
IsNull
IsNumeric
IsObject
VarTypeNew run-time features
- Better string handling.
- Objects for doing file I/O.
Visual Basic for Applications run-time features that are not in the VBScript run time
Category Feature Clipboard Clipboard object Collection Add
Count
Item
RemoveConstants (Lots) Conversion Chr$, Hex$, Oct$
CVar, CVDate
CCur
Format, Format$
Str$
Str, ValDate/Time Date statement, Time statement
Date$, Time$
TimerDDE LinkExecute
LinkPoke
LinkRequest
LinkSendFinancial (Lots) Graphics TextHeight, TextWidth
LoadPicture, SavePicture
QBColor, RGBManipulating objects Arrange, ZOrder, SetFocus
InputBox$
Drag
Hide, Show, Load, Unload, Move
PrintForm, Refresh
AddItem, RemoveItemMiscellaneous Environ, Environ$
SendKeys
Command, Command$
DoEvents
AppActivate, Shell
BeepObjects GetObject Printing TextHeight, TextWidth
EndDoc, NewPage
PrintFormStrings LCase$, UCase$
LSet, RSet
Space$, String$
Format, Format$
Left$, Mid$, Right$
Trim$, LTrim$, RTrim$
StrConvTypes TypeOf Using classes TypeName Variant Support IsMissing 4. Preliminary VBScript Licensing Terms
Customer types
VBScript has three kinds of customers:
- End users. People who use VBScript in some host, such as Internet Explorer.
- Binary component licensees. People who license the VBScript component and host it.
- Source code licensees. People who license the VBScript source code and port it to other platforms.
Licensing agreement
Disclaimer: This document is a preliminary description of the terms under which Microsoft will provide VBScript source and binary versions to third parties. Final terms may differ in material ways.
Binary version licenses
Binary (compiled) versions of the VBScript compiler and run time for Windows (Win 32® and Win16) and the Power Macintosh® will be downloadable from Microsoft's Internet site. These can be integrated into any browser or application using the OLE scripting interface defined by Microsoft and other ISVs. VBScript can be distributed freely with any application that makes use of its capabilities.
Source version licenses
Microsoft will license the source of VBScript to any vendor to accomplish a port and/or integration of the product. In order to ensure interoperability of different VBScript applications, licenses for use of the source of VBScript does not include the right to modify the VBScript language definition as described by Microsoft in its reference implementation.
Products ported or created using the VBScript source may be distributed freely without payment to Microsoft. If licensees create a derivative work of VBScript, they must notify Microsoft and must clearly indicate to users of the product that such derivative work is a modified version and not the original Microsoft software. Further, licensees agree to license such modifications back to Microsoft at no charge for distribution to others.
Microsoft may require from time to time that licensees demonstrate compatibility of VBScript implementations on different platforms. This may be in the form of automated tests provided by Microsoft.
Attribution
All licensees (that is, both binary and source licensees) must agree to include the following in the About box and in any printed or online documentation for their application:
This application uses VBScript from Microsoft Corporation.
Licensees must further agree that any reference to VBScript in their documentation or other product description information be made in an unambiguous way, acknowledging Microsoft's ownership of this technology.
Support model
End users
These will be supported at the same level that Internet Explorer is today. Support for this comes out of the Personal Operating Systems cluster in Product Support Services.
Component licensees
We will go with a per incident charge of $95 with support coming out of our Windows SDK support team in Developer Support.
Source licensees
This will require a $40,000 Premier contract with support coming from the Strategic Customers and Products team in our Premier organization. No additional fee is charged.
5. More Questions and Answers About VBScript
When will VBScript be available?
We anticipate delivery of VBScript in the first half of 1996.
How will hardware manufacturers use VBScript?
VBScript can be used as a batch-automation language on any hardware platform. Hardware vendors may use VBScript to create value-added software for their platforms as well.
How will software designers use VBScript?
VBScript is a freely available automation language that any software vendor can incorporate into its product to provide scripting capability on any platform.
How does VBScript compare to Visual Basic?
VBScript does not include any of the Visual Basic development environment components (that is, the editor, debugger, project manager, or source code control). It has no ability to create user interfaces. All user interfaces manipulated by VBScript must be created as HTML pages, OLE objects, or applets. And, of course, VBScript is free.
Is VBScript safe?
Yes, potentially unsafe language operations have been removed from VBScript.