Home  |  Latest News  |  Contribute  |  F.A.Q.  |  Account  |  Scripts | About
Search ASPNut:
 
ASP Reference
Server Variables
ASP Glossary
Related Sites

Free Components

HTML Reference
Web Colors
Entities
CSS Level 1
Encode/Decode
Glossary

Our Sponsors
ASP Nuke CMS
Free Auctions
PHP 5 Script
Funktastic Blog
ULost Directory
Team Task

 

 

 

 

 

 

 

 

 

 

 

 

ReDim

The ReDim statement allows you to re-dimension the size of a dynamic array at runtime. Why would you want to do this? Imagine the case where you are populating an array from a database but the number of items is always changing.

In most cases, you can just use a new array when you need an array of a different size. Other times, it is more convenient to keep the array name the same and thus resize the existing array. This is done as shown below:

Dim aArray
aArray = Array(10)
' now we have an array that holds 10 elements
ReDim aArray(20)
' now we have an array that holds 20 elements


The ReDim statement is often used with the Preserve statement to resize an array without losing the exiting information. An example of how this is done is shown below:

Dim aArray
aArray = Array(0)
nCount

Randomize
nCount = Int(Rnd() * 10) + 1
For I = 1 To nCount
    ReDim Preserve aArray(I)
    aArray(I) = I
Next

Orvado Technologies

ASP Nuke CMS
Free Open Source
Content Manager
HomeFix Boards
Home Remodeling
Message Boards

Contact Us | Contribute | About | Site Map



"Watching football is like watching pornography. There's plenty of action, and I can't take my eyes off it, but when it's over, I wonder why the hell I spent an afternoon doing it." - Luke Salisbury

©2007 Orvado Technologies, All Rights Reserved
ASP Nut provides articles and reference documentation for Active Server Page developers.