ASP Is Fun

Learning ASP
Free ASP Course
ASP Basics
ASP Functions
SQL Commands
Sample ASP Code


Servers / Setup
ASP Host Reviews
ASP Server Setup
ASP Error Tips


Contract ASP
ASP Development

Search For:


Intro to ASP


 


Redim and Preserve in ASP Arrays



When you're using ASP arrays, sometimes you want to make them larger part way through processing. The Redim command lets you alter an array size - and the preserve command saves the data already there.

Let's say you start out with an array that normally only needs around 5 items in it. So you could do

Dim ShopCart(5)

This would conserve memory space and take into account what most people would use it for. But let's say someone comes along who wants more than 5 items in their shopping cart! You don't want to lose that extra information. So to make the array size larger, you would say

Redim ShopCart(10)

or whatever new size you wanted to bump it up to. One problem, though. A redim command loses any data currently in the array. This might be fine if you're just getting started, but if someone is halfway through shopping it'd be bad to lose their data. In that case, you would instead use -

Redim PRESERVE ShopCart(10)

This keeps the array we had already and just adds more space to it.

ASP Array Function List



Bookmark this site so you can reference it any time you have ASP questions in the future!

Add ASP+Functions+ to Twitter Add ASP+Functions+ to Facebook Add ASP+Functions+ to MySpace Add ASP+Functions+ to Del.icio.us Digg ASP+Functions+ Add ASP+Functions+ to Yahoo My Web Add ASP+Functions+ to Google Bookmarks Add ASP+Functions+ to Stumbleupon Add ASP+Functions+ to Reddit



 


Get Emails when this Site is Updated



ASP Ebooks | Free ASP Course |
All content copyright © 2013 Minerva WebWorks LLC. All rights reserved.

Italian Wedding

Free Newsletter!

Ebooks
Intro to ASP
ASP SQL DB
ASP Members
ASP Shopping


Introduction to ASP

ASP Poll
How do you handle 500 errors?
I don't
Page does nothing
Displays error
Emails error



affiliate_link