Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll

my Blog
[prev. Lesson]  Arrays: Variable Size
     [next Lesson]  Arrays: Resources Online

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

<Test Script Below>


<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

<Test Script Below>


<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>

Chaz Wish List
Tall Tip $5
Grande Tip $20
Venti Tip $39
Tip Jar Thanks
2004 Thanks
2005 Thanks
HUGE Tip -love site