rss search

Static Arrays

line

<%@ LANGUAGE="VBSCRIPT" %>
<%
'Use the Dim statement along with the array name
'to create a static VBScript array
'The number in parentheses defines the array’s upper bound
Dim arrCars(4)
arrCars(0)="BMW"
arrCars(1)="Mercedes"
arrCars(2)="Audi"
arrCars(3)="Bentley"
arrCars(4)="Mini" 

'create a loop moving through the array
'and print out the values
For i=0 to 4
response.write arrCars(i) & "<br>"
Next     'move on to the next value of i
%>

Here is another way to define the array in VBScript:

<%
'we use the VBScript Array function along with a Dim statement
'to create and populate our array
Dim arrCars
arrCars = Array("BMW","Mercedes","Audi","Bentley","Mini") 'each element must be separated by a comma

'again we could loop through the array and print out the values
For i=0 to 4
response.write arrCars(i) & "<br>"
Next
%>
Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter


Leave a Reply

You must be logged in to post a comment.

Devguru.in is Stephen Fry proof thanks to caching by WP Super Cache