0% found this document useful (0 votes)
63 views

VBScript Basics

The document discusses the syntax of VBScript and provides examples of writing "Hello World" in 3 sentences or less: It shows how to write "Hello World" using VBScript by calling the document.write function to output the text. Whitespace and line breaks are ignored in VBScript, allowing code to be freely formatted for readability. Colons and underscores can be used to split long statements across multiple lines for improved readability.

Uploaded by

veereshhsm
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views

VBScript Basics

The document discusses the syntax of VBScript and provides examples of writing "Hello World" in 3 sentences or less: It shows how to write "Hello World" using VBScript by calling the document.write function to output the text. Whitespace and line breaks are ignored in VBScript, allowing code to be freely formatted for readability. Colons and underscores can be used to split long statements across multiple lines for improved readability.

Uploaded by

veereshhsm
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

VBScript - Syntax

Advertisements
Previous Page
Next Page

Your First VBScript


Let us write a VBScript to print out "Hello World".
<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!

Whitespace and Line Breaks


VBScript ignores spaces, tabs and newlines that appear within VBScript programs.
Because one can use spaces, tabs and newlines freely within the program so you are free to
format and indent your programs in a neat and consistent way that makes the code easy to read
and understand.

Formatting
VBScript is based on Microsoft's Visual Basic. Unlike JavaScript, no statement terminators such
as semicolon is used to terminate a particular statement.

Single Line Syntax


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.
<script language="vbscript" type="text/vbscript">

var1 = 10 : var2 = 20
</script>

Multiple Line Syntax


When a statement in VBScript is lengthy and if user wishes to break it into multiple lines, then
the user has to use underscore "_".
This improves the readability of the code. The following example illustrates how to work with
multiple lines.
<script language="vbscript" type="text/vbscript">
var1 = 10
var2 = 20
Sum = var1 + var2
document.write("The Sum of two numbers"&_
"var1 and var2 is " & Sum)
</script>

You might also like