0% found this document useful (0 votes)
8 views3 pages

Section 4

The lab manual provides an overview of VBScript, explaining its integration into HTML using the <SCRIPT> tag and various placement options for scripts. It includes practical exercises across multiple sessions, focusing on tasks such as displaying messages, creating forms, and performing calculations using VBScript. The manual emphasizes the importance of browser compatibility and offers guidance on handling non-supportive browsers.

Uploaded by

a47712165
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Section 4

The lab manual provides an overview of VBScript, explaining its integration into HTML using the <SCRIPT> tag and various placement options for scripts. It includes practical exercises across multiple sessions, focusing on tasks such as displaying messages, creating forms, and performing calculations using VBScript. The manual emphasizes the importance of browser compatibility and offers guidance on handling non-supportive browsers.

Uploaded by

a47712165
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Lab Manual

SECTION 4 VBSCRIPT
Structure
4.0 VBScript Basics
4.1 Incorporating VBScript into HTML Page
4.2 Exercises for Practice in Lab Sessions

4.0 VBSCRIPT BASICS


VBScript is a powerful and easy to learn tool that can be used to add interaction to
your Web pages.

The Web browser receives scripts along with the rest of the Web document. The
browser parses and processes the scripts. HTML was extended to include a tag that is
used to incorporate scripts into HTML-the <SCRIPT> tag.

4.1 INCORPORATING VBSCRIPT INTO HTML PAGE


To add scripts into your Web pages <SCRIPT> tag is used. The <SCRIPT> tag
signifies the start of the script section, while </SCRIPT> marks the end. An example
of this is shown below:
<HTML>
<HEAD>
<TITLE>Working With VBScript</TITLE>
<SCRIPT LANGUAGE="VBScript">
<!--
MsgBox "Welcome to my Web page!"
-->
</SCRIPT>

The LANGUAGE attribute of SCRIPT tag specifies the language used for scripting.
Scripts are usually placed at the top of the Web document, in the HEAD. There are
four different places where you can use scripts:

• In the body of the page. In this case, the output of the script is displayed, as part
of the HTML document, when the browser loads the page.
• In the header of the page, between the <HEAD> tags. Scripts in the header
aren’t executed immediately, but can be referred to by other scripts. The header
is often used for functions-groups of VBScript statements that can be used as a
group.
• Within an HTML tag. This is called an event handler and allows the script to
work with HTML elements. Event handlers are the one type of script where you
don’t need to use the <SCRIPT> tag.
• In a separate file entirely.

Not all browsers support scripting languages. To handle such browsers you can
enclose your script in comment tags (<!-- and -->).

4.2 EXERCISES FOR PRACTICE IN LAB SESSION


SESSION 1
Exercises

18 1. Write a programme to display the following on a Web page:


Hello <User_Name> VBScript

2. Create a Web page that displays a message box with the message:

“Welcome to my Website”

3. Write code to change colour of text randomly.

SESSION 2
Exercises
1. Write a VBScript code that accepts the length, breadth and height and displays
the area of a rectangle.

2. Create a programme to generate a hit counter.

SESSION 3
Exercises
1. Write a programme, which prompts, the user to enter the sum of two numbers
and display whether the answer is correct or incorrect.

2. Using VBScript, create a calculator.

SESSION 4
Exercises
1. Create a programme to check for null or empty string.

2. Create a form that has an e-mail field. Now write VBScript code for validation
of the email address.

SESSION 5
Exercises
1. List the Mouse and Keyboard events in VBScript.

2. How do you generate a random number in VBScript?

SESSION 6
Exercises
1. Create a form in HTML containing the following fields and then perform the
validation of each field using VBScript.

Name - textbox
Address - textbox
Date of Birth - a combo box (one for each, day, month and
year)
Email - textbox

2. How do you declare variables in VBScript and enlist the various variables-
naming rules.

19
Lab Manual SESSION 7
Exercises
1. What is the purpose of Option Explicit in VBScript code?

2. Using an HTML form accept the Principal, Rate of Interest and Time from the
user, validate the three fields and then display the Simple Interest to the user.

SESSION 8
Exercises
1. Create a programme that accepts the time from the system clock and
accordingly displays a Good Morning, Good Afternoon or Good Evening
message to the user. Use If – Then – Else statement.

2. Create the above programme using Select Case.

SESSION 9
Exercises
1. Write a programme in VBScript that uses For..Next looping statement to create
a Fibonacci series.

2. Using Do..While loop display the factorial of a number.

SESSION 10
Exercises
1. Write a programme that displays the multiplication of two matrices.

2. Write a programme that displays the transposition of a matrix.

3. Write a programme that accepts a number from the user and displays its
factorial only if it is a prime number.

20

You might also like