VBScript Syntax



A. First VBScript Example :

Consider the following VBScript Example –

<html>
<body>
<script language="vbscript" type="text/vbscript">
   document.write("Hello World!")
</script>
</body>
</html>

Output :

Hello World!

Explanation :

In order to include the VBScript code in the HTML page we need to write the code in the script tag like this –

<script language="vbscript" type="text/vbscript">

In the above example, we have written the following statement

document.write("Hello World!")

It prints the message on the HTML document.

B. Comments in VBScript :

VBScript provides two types of comments.
VBScript Comment

1. Statement starting with a Single Quote :

<script language="vbscript" type="text/vbscript">
<!—
  ' This is sample Script
  ' Parameters : rem
  ' Return Value : True / False
//- >
</script>

2. Statement starting with keyword “REM” :

<script language="vbscript" type="text/vbscript">
<!—
  REM This is sample Script
  REM Parameters : rem
  REM Return Value : True / False
//- >
</script>

Comments are ignored by interpreter. Generally comments are used for the documentation purpose or for hiding some piece of code.