|
Arrays to
store data Part 3 by Charles Carroll
There is a code intensive way to load an
array and a less intensive one. For example, here is the code intensive one:
filename=/learn/test/arraysload.asp
<html><head>
<title>arraysload.asp</title>
</head><body bgcolor="#FFFFFF">
<%
dim my_months(13)
my_months(0)=""
my_months(1)="Jan"
my_months(2)="Feb"
my_months(3)="Mar"
my_months(4)="Apr"
my_months(5)="May"
my_months(6)="Jun"
my_months(7)="Jul"
my_months(8)="Aug"
my_months(9)="Sep"
my_months(10)="Oct"
my_months(11)="Nov"
my_months(12)="Dec"
lowcount=lbound(my_months)
highcount=ubound(my_months)
response.write "lowcount=" & lowcount & ";highcount=" & highcount & "<p>"
for counter=lowcount to highcount
response.write my_months(counter) & "<br>"
next
%>
</body></html>
Here is the less code intense one:
filename=/learn/test/arraysloadbest.asp
<html><head>
<title>arraysloadbest.asp</title>
</head><body bgcolor="#FFFFFF">
<%
dim my_months
my_months=array("Jan","Feb","Mar","Apr", _
"May","Jun","Jul","Aug", _
"Sep","Oct","Nov","Dec")
' finally here is how you loop through an array
lowcount=lbound(my_months)
highcount=ubound(my_months)
response.write "lowcount=" & lowcount & ";highcount=" & highcount & "<p>"
for counter=lowcount to highcount
response.write my_months(counter) & "<br>"
next
%>
</body></html>
|