Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
10Activity
0 of .
Results for:
No results containing your search query
P. 1
What is VBScript

What is VBScript

Ratings: (0)|Views: 144|Likes:
Published by palegreat

More info:

Published by: palegreat on Nov 27, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

09/21/2011

pdf

text

original

 
What is VBScript?VBScript, Microsoft's Visual Basic Scripting Edition, is a scaled down version of VisualBasic. While it doesn't offer the functionality of Visual Basic, it does provide apowerful, easy to learn tool that can be used to add interaction to your web pages.If you are already experienced in either Visual Basic or Visual Basic for Applications,you will find working with VBScript easy and should be
immediately productive
.Don't be concerned if you haven't worked in another version of Visual Basic.VBScript is easy to learn, even for the novice developer.Adding VBScript to Web PagesScripting languages, like JavaScript and VBScript, are designed as an extension toHTML. The web browser receives scripts along with the rest of the web document. Itis the browser's responsibility to parse and process the scripts. HTML was extendedto include a tag that is used to incorporate scripts into HTML-the
<SCRIPT>
tag.
The <SCRIPT> Tag
You add scripts into your web pages within a pair of 
<SCRIPT>
tags. The
<SCRIPT>
tag signifies the start of the script section, while
</SCRIPT>
marks the end. Anexample of this is shown below:
<HTML><HEAD><TITLE>Working With VBScript</TITLE><SCRIPT LANGUAGE="VBScript">MsgBox "Welcome to my Web page!"</SCRIPT>
The beginning
<SCRIPT>
tag includes a
LANGUAGE 
argument that indicates thescripting language that will be used. The
LANGUAGE 
argument is required becausethere is more than one scripting language. Without the
LANGUAGE 
argument, a webbrowser would not know if the text between the tags was JavaScript, VBScript oranother scripting language.While technically you can place scripts throughout an HTML document using pairs of 
<SCRIPT>
tags, typically scripts are often found at either the top or bottom of aWeb document. This provides for easy reference and maintenance.
Handling Non-Supporting Browsers
Not all browsers support scripting languages. Some only support JavaScript. OnlyMicrosoft's Internet Explorer supports VBScript. You might be wondering whathappens to your scripts when non-supporting browsers encounter them. Usuallybrowsers will do what they do most frequently with text, they will display yourscripts as part of the web page. Obviously, this isn't the result you had hoped for.One simple way to address this problem is to encase your scripts in comment tags
 
(<!--
and
-->)
. Below is our example script as it appears with the addition of thecomment tags:
<HTML><HEAD><TITLE>Working With VBScript</TITLE><SCRIPT LANGUAGE="VBScript"><!--MsgBox "Welcome to my Web page!"--></SCRIPT></HEAD></HTML>
Now, when a browser that does not support VBScript processes this page, it willview your script as a comment and simply ignore it.Working with VariablesA variable is a named location in computer memory that you can use for storage of data during the execution of your scripts. You can use variables to:
Store input from the user gathered via your web page
Save data returned from functions
Hold results from calculations
 An Introduction to Variables
Let's look at a simple VBScript example to clarify the use of variables.
Sub cmdVariables_OnClickDim NameName = InputBox("Enter your name: ")MsgBox "The name you entered was " & NameEnd Sub
The first line of this example defines a sub procedure associated with the click eventof a command button named
cmdVariables
.
 
On the second line we declare a variable named
Name
. We are going to use thisvariable to store the name of the user when it is entered. The third line uses the
InputBox 
function to first prompt for, and then return, the user's name. You will seemore of the
InputBox 
function later in this tutorial. The name it returns is stored inthe
Name
variable.The fourth line uses the
MsgBox 
function to display the user's name. Finally, the subprocedure completes on line five.Exactly how, and where, variables are stored is not important. What you use themfor, and how you use them is important. That is what we will be looking at next.
Declaring Variables
There are two methods for declaring variables in VBScript, explicitly and implicitly.You usually declare variables explicitly with the
Dim
statement:
Dim Name
This statement declares the variable
Name
. You can also declare multiple variableson one line as shown below, although it is preferable to declare each variableseparately:
Dim Name, Address, City, State
Variables can be declared implicitly by simply using the variable name within yourscript. This practice is not recommended. It leads to code that is prone to errors andmore difficult to debug.You can force VBScript to require all variables to be explicitly declared by includingthe statement
Option
 
Explicit 
at the start of every script. Any variable that is notexplicitly declared will then generate an error.Variable Naming RulesWhen naming variables the following rules apply:
They must begin with an alphabetic character
They cannot contain embedded periods
They must be unique within the same scope. There is more on scopes later inthis lesson
They must be no longer than 255 charactersVariants and SubtypesVBScript has a single data type called a
variant 
. Variants have the ability to storedifferent types of data. The types of data that a variant can store are referred to as
subtypes
. The table below describes the subtypes supported by VBScript. 

Activity (10)

You've already reviewed this. Edit your review.
1 hundred reads
Gurumurthy G S liked this
josephvimalan liked this
josephvimalan liked this
Chandan Dash liked this
aniljad liked this
srepuri liked this
mailanbazhagan liked this
hondaxrv liked this
92saif liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->