Language features The VBScript language is modeled on classic Visual Basic. Notable features include: A "procedure" is the main construct in VBScript for separating code into smaller modules. VBScript distinguishes between a function, which can return a result in an assignment statement, and a subroutine, which cannot. Parameters are positional, and can be passed by value or by reference. Control structures include the usual iterative and conditional Do Loops, If-Then-Else statements, and Case statements, with some more complex variants, such as ElseIf and nested control structures. As a memory aid in coding, and certainly for readability, there are a large number of constants, such as and for logical values, and for codes, and for color values, for the carriage return character, and many others. Variables have "
Variant" type by default, but it is possible (and sometimes necessary) to force a particular type (integer, date, etc.) using conversion functions (, , etc.) User interaction is provided through the functions MsgBox and InputBox which provide a simple dialogue box format for messages and input. Both functions display prompting messages, with the former returning a standard response, and the latter returning one user-supplied text or numeric value. For more elaborate GUI interaction with controls, VBScript can be used in combination with HTML, for example, in an
HTML Application. Event-driven forms are not supported as in Visual Basic or
Visual Basic for Applications. Names are not case-sensitive. However, it is considered a best practice of VBScript style to be consistent and to capitalize judiciously.
VBScript functionalities When hosted by the
Windows Script Host, VBScript provides numerous features which are common to scripting languages, but not available from
Visual Basic 6.0. These features include: • Named and unnamed command line arguments •
Stdin and
stdout, which could be redirected • WSH.Echo which writes to the console and cannot be redirected • WSH.ExitCode which can be tested from DOS batch files, or by the process which invoked the script file • Network printers • Network shares • Special folders, e.g. Desktop, Favorites, MyDocuments and so on • Network user information, such as group membership • Methods for runtime execution of text defined at runtime: Eval and Execute • Methods for executing scripts on remote machines •
Windows Management Instrumentation (WMI) • Functionality for embedding a VBScript engine in other applications, using a widely known language CScript, the command line runner, provides options for: • Interactive or batch mode • Invoking debug mode from the command line • Error reporting including the line number
Additional functionality File system management, file modification, and streaming text operations are implemented with the Scripting Runtime Library scrrun.dll. This provides objects such as FileSystemObject, File, and TextStream, which expose the Windows file system to the programmer. Binary file and memory I/O are provided by the "ADODB.Stream" class, which can also be used for string builders (to avoid excessive string concatenation, which can be costly), and to interconvert byte arrays and strings. Database access is made possible through
ActiveX Data Objects (ADO), and the IIS Metabase can be manipulated using the GetObject() function with sufficient permissions (useful for creating and destroying sites and virtual directories). XML files and schemas can be manipulated with the
Microsoft XML Library Application Programming Interfaces (, ), which also can be used to retrieve content from the World Wide Web via the XMLHTTP and ServerXMLHTTP objects (class strings "MSXML2.XMLHTTP.6.0" and "MSXML2.ServerXMLHTTP.6.0", respectively). Functionality can also be added through ActiveX technologies. Security concerns have led to many ActiveX controls being blacklisted in the Internet Explorer process by Microsoft, which deploys the
killbit via monthly Windows security updates to disable vulnerable Microsoft and third party code. Programmers can utilize the extensibility via COM (ActiveX) modules to specifically equip the Script Host and VBScript with required or desired functions. The "VTool" component, for instance, adds a number of dialog windows, binary file access, and other functionality. ==Development tools==