iNET Interactive - Online Advertising Agency
          
   Home    Authors    About    Login    Contact Us
   Search:   
Advanced Search     
  Articles

  ASP (26)
  ASP.NET (19)
  C and C++ (4)
  CFML (2)
  CGI and Perl (16)
  Flash (2)
  Java (7)
  JavaScript (28)
  PHP (92)
  MySQL (13)
  MSSQL (3)
  HTML (35)
  SEO (9)
  Visual Basic (12)
  CSS (13)
  SSI (5)
  XML (12)
  C# (14)

  Developer News

September 7, 2008
Web Design Clinic - Art meets Webdesign
About
 
September 6, 2008
Browser safe colors - do we care?
About
 
September 6, 2008
Get a Daily CSS Tip
About
 
September 5, 2008
It's safe to use Google Chrome now
About
 
September 5, 2008
Add a comment
.net
 
September 5, 2008
The Partial Function Application in JavaScript
WebReference.com
 
Courtesy of moreover.com
 
Want to receive new articles via e-mail? Click here!
/Home /Visual Basic

VBScripts Tutorial I 

  Views:    20072
  Votes:    4
by Ahmad Permessur 12/12/03 Rating: 

Synopsis:

Welcome to a new series of tutorials on VBScripts. Throughout several lessons, I’ll teach you VBScripts. This isn't a hard thing to do, and it'll enhance your pages. In today’s lesson, I’ll focus a bit on the VBScript language itself, and on variables.
Pages: firstback1 3 forwardlast
The Article

Adding VBScript to your page.

Adding scripts to your Web pages is easy. All you have to do is place the begin tag <SCRIPT> where the script starts and the end tag </SCRIPT> where it ends. The <SCRIPT> tag has one attribute called LANGUAGE, which identifies the scripting language you're using. Since you're creating scripts in VBScript, use the value LANGUAGE="VBScript" to tell this to your browser.

Here's an example of how to add a script to your page:

<HTML>
<HEAD>
<TITLE>Example</TITLE>
</HEAD>
<BODY>
 
<!--
<SCRIPT LANGUAGE="VBScript">
 
Insert your script here!
 
-->
</SCRIPT>
 
</BODY>
</HTML>
 
 
Although the most popular browsers available today support scripts, browsers that don't support scripts display your script's code with the contents of your Web page. To avoid this problem, follow the begin script tag with a begin comment tag, and precede the end script tag with an end comment tag as in the above example.

Throughout this article, I’ll be using several examples, and I’ll be giving only the VBScript part, so if you want to try the scripts, just copy the above HTML codes and inserts your scripts between the <SCRIPT> tags.  Then paste it in notepad or any text editor of your choice and save it as .html and run it in your browser.
 
Variables
 
Giving the variable a name, which you can later refer to the variable by name in your code, easily creates variables in VBScripts both explicitly and implicitly.

When you declare an explicit variable, you tell VBScript with the keyword Dim that you're creating a variable, and then follow the Dim keyword with the variable name. If you wanted to explicitly declare a variable called eValue, you could use the following:

<SCRIPT LANGUAGE="VBScript">

<!--

Dim eValue

eValue = eValue + 1

-->

</SCRIPT>

When you implicitly declare a variable, you use the variable without first declaring it, so you don't need to use the Dim keyword. VBScript creates the variable for you as necessary. If you wanted to use a variable called iValue implicitly, you could use the following:

<SCRIPT LANGUAGE="VBScript">

<!--

iValue = 150

-->

</SCRIPT>

Pages: firstback1 3 forwardlast

Similar/related articles:


 
  Sponsors