Search Tools Links Login

Beginners Guide to Arrays

Do you want to store MANY variables in one name? Try Arrays! This Tutorial will Teach you the basics of Creating Arrays! Including MultiDemensional Arrays!

Original Author: L124RD


Beginner's Guide to Arrays


Have you wanted to store 300 integers in a variable? like variable d? well now you can with the Beginner's Guide to Arrays!

Regular Arrays

Arrays are a way of storing data. instead of using 13 variables to hold 13 different integers you can use one to hold all thirteen! using the following code:

dim K(12) as integer

That code holds 13 integers in Variable K. Arrays start at 0 so if you wanted to create 300 integers you'd say 'dim K(299) as integer' instead of dim'ing K1 - K300.

When Setting Arrays equal to something you use the following Statement:

K(1) = 3

This would create part 2 of K equal to 3. You can put any integer equivilant or equal to the number you put inside of the brakets when you dim'ed K.

Multi-Demensional Arrays

Multi Demensional Arrays are basically the same as Regular Arrays except for one thing. there are more then 1 dimension. Multi-Dimensional Arrays allow you to create Matrixs or even 7d Tables (Don't ask me what those look like). Multi Dimensional Arrays are used for many things. Score Cards and tables are examples of 2 dimensional arrays and 3d Axis' are a examples of 3 Dimensional Arrays. Multi Dimensional Arrays are dim'ed like so:

Dim K(1,1) as integer

That creates 4 K's. You can acess the Variables by:

K(0,1) = K(1,0)

That makes whatever 0,1 on the table is equal to whatever 1,0 is.

Thats it for Arrays. Enjoy your stay at PSC!


About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 78 times


Visual Basic 6


No attachments for this post

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.