Displaying Source Code(s)
|
|
Arrays to store data
--------------------------------------------------------------------------------
Description : 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
<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.
<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>
|
|
|