Amazon.com: PC Books || Educational Software || Magazines
Amazon: Books-CA || Software-CA || Books-UK || Software-UK

HTML | Javascript | ASP | PHP | VBScript | SQL | Hardware | PC FAQ| WinXP|

Learn to Build, Upgrade, or Repair your Computer Ebook + PC Safety 101 kwwebservice.com Reasonably priced web development & hosting
ASP Basics
Introduction
Variables & Arrays
Sub & Functions
If Statements
Case Statements
Loop Statements
Date Objects
Form Processing
Text File Objects
Database Access
Adding Record
Updating Record
Deleting Record
Virtual Includes
Cookies
Server Variables
Creating Login Page
E-mail
ASP Books @
CA Amazon
UK Amazon
US Amazon

  :: Home
PC Topics
  :: Build A PC
  :: Windows XP
  :: PC Help
Tutorials
  :: HTML
  :: JavaScript
  :: ASP
  :: PHP
  :: VBScript
  :: SQL
Miscellaneous
  :: Code/Scripts
  :: Forum
  :: Links
  :: Contact us
  :: Tell A Friend
  :: In Somali
  ::
Web Articles
  Top Web Hosting
Reviews
  Processing
Online Card Payment Guide
  Domain name
registration & buying guide
  Getting
a website online guide
  Search Engine
submission & optimization tips
Netfirms Web Hosting
Free trial
Quality business correspondence.
Yahoo! Search Marketing

ASP Variable

ASP variables are declared using VBScript declaration type.   Assumming VbScript is used, this is how you declare variable: DIM varaibleName or Const variableName.  If you want reject undeclared variables, use <% Option Explicit %> at the beginning of your page.  You would often see these two lines:
<%@ Language="Vbscript" %>
<% Option Explicit %>
at the beginning of ASP pages.  First line sets the language and the second line watches undeclared variables.  VBScript and JavaScript variables are variant type variable, which means they can take any type of values.  Any variable name must start with letter or underscore.
Watch this program to see how variables are used:
<%
   Dim name, email, age
   name="John M"
    email="you@you.com"
   age=356
    response.write("Your Name: " & name & "<br>")
    response.write("Your Email: " & email & "<br">)
    response.Write("Your age: " & age);
%>

The following is the result from the above example:

Your Name: John M
Your Email: you@you.com
Your Age: 365

ASP Arrays

An array is an indexed list of things called elements or group of related variables. For example, say that we want declare variables for list of cars like this; Dim car1, car2, car2, car3,....
Here is how you would declare list of cars using array:
Dim cars(3); We simply declared array that takes 4 items.  To assign values to this array, do these:
cars(0)="Jeep Grand Cherokee"
cars(1)="Jeep Wrangler"
cars(2)="Jeep Liberty"
cars(3)="Jeep Cherokee Briarwood"
Use this statement to write an item in the array: response.write(cars(3)) This will write the 4th car on the list.
Here is the example we did in code
ExampleExplanation
<%
dim cars(3)
cars(0)="Jeep Grand Cherokee"
cars(1)="Jeep Wrangler"
cars(2)="Jeep Liberty"
cars(3)="Jeep Cherokee Briarwood"
response.write(cars(0)&", ")
response.write(cars(1)&", ")
response.write(cars(2)&", ")
response.write(cars(3))
%>
This is simply illustration, NOT good example.   If you writing items from an array, you would probably write all the items at one time using loops instead of listing response.write statements.
To write the array using for loop statement, do this.
ExampleExplanation
<%
dim cars(3)
dim x
cars(0)="Jeep Grand Cherokee"
cars(1)="Jeep Wrangler"
cars(2)="Jeep Liberty"
cars(3)="Jeep Cherokee Briarwood"
for x= 0 to 3
  response.write(cars(x)&"
")
next%>
The variable x which starts from 0 to 3 acts as an index for the array.

Two dimensional Arrays

You can define two or more dimensional arrays by puting numbers withing the parenthesis.  Here is how you would define two dimensional array Dim cars(3,3).  The reason you may use this type of array is when you have records of each item.  For example, car, year, price,... and you want display one record at a time.
The following is an example of two dimensional array:
ExampleExplanation
<%
dim car1(3,2)
dim x,i
car1(0,0)="Jeep Grand Cherokee"
car1(0,2)=2002
car1(1,1)="Jeep Wrangler"
car1(1,2)=2002
car1(2,1)="Jeep Liberty"
car1(2,2)=2003
car1(3,1)="Jeep Cherokee Briarwood"
car1(3,2)=2003
for x=0 to 3
for i =0 to 2
response.write(car1(e,&a))
next
response.write("
"&" ")
next>
This array has three cars and each car has two fields or columns.  It's like a table, row 0 has record of one car, row 1 has record of another car and so on  We also define nested for loops.  First one reads the row and second one reads the column.
Introduction to ASP Sub Procedure
Listed @ ConsumerVote.com - The Consumer Rated Web Directory
PC Articles
  Computer Safety
prevent viruses & Spyware