Variables and Expressions in VBScript

This section provides tutorial examples on how to use variables and expressions in VBScript language.

Special rules about variables and expressions:

Here is a sample ASP page, variable.asp:

<script language="vbscript" runat="server">
'  variable.asp
'  Copyright (c) 2002 by Dr. Herong Yang
'  This program demonstrates some special rules about variables and 
'  expressions.
'
   response.write("<html><body>")
   response.write("<b>Tests on variables</b>:<br/>")
   i = 1 + 2 + 3
   s = "Sum = "
   s = s & i & "<br/>"
   i = i=6
   response.write(s)
   response.write("Is the answer correct? " & i)
   response.write("</body></html>")
</script>

Output:

Tests on variables:
Sum = 6
Is the answer correct? True

"i = i=6" is a very unusual statement. First of all, variable "i" has changed its data type from integer to Boolean. Secondly, two "=" signs are used next to each other, the first one is an assignment operation, and the second one is a Boolean equality operator.

Last update: 2003.

Table of Contents

 About This Book

 ASP (Active Server Pages) Introduction

 IIS (Internet Information Services) 5.0

 MS Script Debugger

VBScript Language

 Using VBScript in ASP Pages

 Mixing VBScript Statements with Static HTML Text

Variables and Expressions in VBScript

 Arrays and Loops in VBScript

 "Collection" Class in VBScript

 ASP Built-in Run-time Objects

 ASP Session

 Creating and Managing Cookies

 Managing Sessions with and without Cookies

 scrrun.dll - Scripting Runtime DLL

 Managing Response Header Lines

 Calculation Speed and Response Time

 ADO (ActiveX Data Object) DLL

 Working with MS Access Database

 Guest Book Application Example

 References

 PDF Printing Version