logo
g Text Version
Auto
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Society & Culture
Sports
Travel & Leisure
TV & Movies

dailyclick
Bored? Games!
Postcards
Astrology
Take a Quiz
Rate My Photo

new
Jokes & Riddles
Astronomy
Philosophy
Public Health
Canadian Culture


dailyclick
All times in EST

Autism Spectrum Disorders: 4:00 PM

Full Schedule
g
g ASP Site
Editor Wanted
BellaOnline's ASP Editor

g

Defining and Using Arrays in ASP
Guest Author - Lisa Shea

Interested in using arrays to help you organize your variables? Arrays can help you 'group' sets of information together, like the names of states, or names of countries, or colors, or any other grouping.

What is an array? An array is a variable that has multiple 'buckets' associated with it. Instead of creating variables called Book1, Book2, Book3, Book4, Book5, and so on, you simply make one array:

Dim Book(20)

and that one array holds a group of values in one neat little package. This can be great for keeping together sets of information, or looping through 'each book' without having to write code to look at each variable one by one.

First off, note that arrays start with *0* and not with *1*. So if you use:

Dim Oceans(6)

You then have access to:

Oceans(0) = 'Indian'
Oceans(1) = 'Pacific'
Oceans(2) = 'Atlantic
...

And so on. You always begin with spot "0".

If you start out with an array and waht to change its size later on, just use the Redim command. So you can say:

Dim ChessPieces()
Redim ChessPieces(32)

Note that arrays don't need to have just one dimension (the '32' in our last example). You can have two dimensions, or up to 60 dimensions. Why would you want this? Well, let's take our chessboard example. Say you wanted an array location to indicate each spot on a chessboard, so you could track pieces moving from one spot to another. You could do:

Dim ChessSquares(64)

But then every time a piece moved you'd have to figure out where in that '64' it belonged. This could get tricky. What if instead you said:

Dim ChessSquares(8,8)

Now it's easy! Now you simply number the rows of the board from 1-8, and the columns of the board from 1-8, and change each number separately. If a Black Pawn moved from row 2, column 4 to row 3, column 4, you could say:

ChessSquares(2,4) = "EMPTY"
ChessSquares(3,4) = "BP"

Online ASP Course
ASP Array Function List

Introduction to ASP Ebook

Download this ebook to get everything you need to know about learning ASP - from a step by step tutorial to function lists, sample code, common errors and solutions, and much more! 101 pages.

This site needs an editor - click to learn more!

Online ASP Course
RSS
Related Articles
Previous Features
Site Map


Content copyright © 2008 by Lisa Shea. All rights reserved.
This content was written by Lisa Shea. If you wish to use this content in any manner, you need written permission. Contact BellaOnline Administration for details.

Digg! g delicious Save to Del.icio.us

g


For FREE email updates, subscribe to the ASP Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor

g features
Best uses for RSS

RSS and its future.

Force Download Dialog box with ASP

Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Driving Amount
Much more
Slightly more
Slightly less
Much less

g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2008 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor