Tutorials2u.com

Tutorials on various topics

arrays in VBScript

arrays in VBScript

Arrays

What if you want to declare numerous values to a single variable . This is when we use an array . To declare an array we use the same syntax as a normal variable declaration but add ( ) on the end .

Here is an example

dim grades(4)

How many elements do you think we have created here is it 4 , in fact we have created 5 because arrays are zero based . This is an example of a fixed size array.

We can assign data to the array like this

grades(0) = 50
grades(1) = 80
grades(2) = 94
grades(3) = 12
grades(4) = 25

You can retrieve the data like this

myGrade = grades(0)

which would store the value 50 in myGrade

You can have more than one dimension in an array , for example here is a 2 dimensional array

Dim tictactoe(2,2)

this would create an array with 3 columns and 3 rows.

The total amount of dimensions you can have is 60

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Last Entries

Archives


Links