Vbscripttutorial Audience Prerequisites: About The Tutorial
Vbscripttutorial Audience Prerequisites: About The Tutorial
Vbscripttutorial Audience Prerequisites: About The Tutorial
VBScriptTutorial
Microsoft VBScript (Visual Basic Script) is a general-purpose, lightweight and active scripting
language developed by Microsoft that is modeled on Visual Basic. Nowadays, VBScript is the
primary scripting language for Quick Test Professional (QTP), which is a test automation tool.
This tutorial will teach you how to use VbScript scripting language in your day-2-day life of any
Web based or Automation project development.
Audience
This tutorial has been prepared for the beginners to help them understand basic-to-advanced
functionality of VBScript. After completing, this tutorial you will find yourself at a moderate level
of expertise in using Microsoft VBScript from where you can take yourself to next levels.
Prerequisites
Before you start doing practice with various types of examples given in this reference, I'm
making an assumption that you are already aware about what is a computer program and what
is a computer programming language.
All the content and graphics on this tutorial are the property of tutorialspoint.com. Any
content from tutorialspoint.com or this tutorial may not be redistributed or reproduced in any
way, shape, or form without the written permission of tutorialspoint.com. Failure to do so is a
violation of copyright laws.
This tutorial may contain inaccuracies or errors and tutorialspoint provides no guarantee
regarding the accuracy of the site or its contents including this tutorial. If you discover that the
tutorialspoint.com site or this tutorial content contains some errors, please contact us at
[email protected] TUTORIALS POINT Simply Easy Learning
Table of Content
VBScript Tutorial ...................................................................... 2
Audience .................................................................................. 2
Prerequisites ............................................................................ 2
Copyright & Disclaimer Notice .................................................. 2
VBScript - Overview ............................................................... 11
Features of VBScript ................................................................................ 11
VBscript Version History and Uses ....................................................... 11
Disadvantages ......................................................................................... 12
Where VBScript is Today ? ...................................................................... 12
EXAMPLE 1: ........................................................................................... 25
EXAMPLE 2: ........................................................................................... 26
EXAMPLE 3: ........................................................................................... 26
Syntax : .................................................................................................... 67
Example ................................................................................................... 68
NUMBER FORMATING FUNCTIONS .................................................... 68
Syntax : .................................................................................................... 69
Description ............................................................................................... 69
Settings .................................................................................................... 69
Example : ................................................................................................. 69
MATHEMATICAL FUNCTIONS .............................................................. 70
Syntax : .................................................................................................... 71
TUTORIALS POINT Simply Easy Learning
Description ............................................................................................... 71
Example ................................................................................................... 71
CHAPTER
1
VBScript -Overview
BScript stands for Visual Basic Scripting that forms a subset of Visual Basic for Applications
(VBA).
VBA is a product of Microsoft which is included NOT only in other Microsoft products such as MS Project
and MS Office but also in Third Party tools such as AUTO CAD.
Features of VBScript
Unlike C++ or Java, VBScript is an object-based scripting language and NOT an Object-Oriented
Programming language.
It uses Component Object Model (COM) in order to access the elements of the environment in which
it is executing.
Successful execution of VBScript can happen only if it is executed in Host Environment such as
Internet Explorer (IE) ,Internet Information Services (IIS) and Windows Scripting Host (WSH)
Windows Scripting Host, which is used mostly by Windows System administrators for automating the
Windows Desktop.
Active Server Pages (ASP), a server side scripting environment for creating dynamic webpages
which uses VBScript or Java Script.
Microsoft Outlook Forms usually runs on VBScript; however, the application level programming relies
on VBA (Outlook 2000 onwards).
Disadvantages
VBscript is used only by IE Browsers. Other browsers such as Chrome, Firefox DONOT Support
VBScript. Hence, JavaScript is preferred over VBScript.
VBScript Syntax
Your First VBScript
<html>
<body>
<script language="vbscript" type="text/vbscript">
document.write("Hello World!")
</script>
</body>
</html>
In the above example, we called a function document.write, which writes a string into the HTML
document. This function can be used to write text, HTML or both. So, above code will display following
result:
Hello World!
Formatting
VBScript is based on Microsoft's Visual Basic. Unlike JavaScript, no statement terminators such as
semicolon is used to terminate a particular statement.
Colons are used when two or more lines of VBScript ought to be written in a single line. Hence, in
VBScript, Colons act as a line separator.
CHAPTER
Reserved Words
The following list shows
the reserved words in
VBscripting. These
reserved words SHOULD
NOT be used as a
constant or variable or
any other identifier
names. Loop
Mod
Not
On
Or
Private
ReDim
Rset
Shared
Stop
To
And
ByRef
Call
Const
Dim
Lset
Me
New
Nothing
Option
ParamArray
Public
Rem
Select
Single
Sub
True
As
Byte
Case
Currency
Do
Next
Null
Optional
Preserve
RaiseEvent
Resume
Set
Static
Then
Type
Boolean
ByVal
Class
Debug
Double