|
Arrays to
store data Part #2 by Charles Carroll
Assigning an array size with a variable
produces a variable unless the Redim command is used.
- Method #1: You know the size
- Method #2: the size is in a variable
filename=/learn/test/arraysredim.asp
<html><head>
<title>arraysredim.asp</title>
</head><body bgcolor="#FFFFFF">
<%
' this code
dim a_array(100)
' this code will fail
x=100
dim my_array(x)
%>
</body></html>
Assigning an array size with a variable produces an
error unless the Redim command is used.
filename=/learn/test/arraysredimcorrect.asp
<html><head>
<title>arraysredimcorrect.asp</title>
</head><body bgcolor="#FFFFFF">
<%
dim my_array()
x=100
redim preserve my_array(x)
my_array(20)="Hi!"
my_array(40)="How are You"
lowcount=lbound(my_array)
highcount=ubound(my_array)
response.write "lowcount=" & lowcount & ";highcount=" & highcount & "<p>"
for counter=lowcount to highcount
response.write counter & " "
response.write my_array(counter) & "<br>"
next
%>
</body></html>
 |  |  |
 |
There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too.
a $5 tip buys him lunch at McDonalds,
a $20 tip buys his kid Hitoshi a new computer game,
a $39 tip buys his daughter Michiko a few nice outfits.
See our donor list.
|  |
 |  |  |
|
|
|
|