To read the article online, visit

Passing Arrays from One ASP Page to Another, Part 2

In Part 1, we looked at how to create an array and encode it for passing it to another web page. In this part of the article, we are going to look at how to receive this information and decode it back into an array.

When variables are passed from one ASP page to another, either via the querystring or a form, when multiple variables have the same name, the Request object creates a comma-delimited list containing all of the values that have the same name. For example, if you call an ASP page with the following querystring:

and then print out the value of Request("Pets") in SomePage.asp, you will receive the following output:

Barney, Alexis, Spud

We can use the split function to turn this comma-delimited list into an array! If you are unfamiliar with split, be sure to read Parsing with join and split.

So, in ReceiveArray.asp, we need to begin with reading in the WeekDays variable, that was passed in via either the querystring or a form. Next, we need to create an array variable (aWeekDays), and use split to populate this array with the comma-delimited list sent from CreateArray.asp. Let's look at some code!

'Read in the WeekDays Array Dim strWeekDays strWeekDays = Request("WeekDays") 'strWeekDays is a comma-delmited list of values 'So we can split on the comma to create an array! Dim aWeekDays aWeekDays = split(strWeekDays, ",")

Isn't this neat? We've just created an array named aWeekDays in ReceiveArray.asp that is nearly identical to the aWeekDays array we created in CreateArray.asp! The only discrepency between the two is that the aWeekDays array in ReceiveArray.asp contains a space as the first character for all elements but the first. This is because the comma-delimited list represented by strWeekDays contains a space after each comma. So, to fix this, we need to iterate through the array, Trimming each element. The following code will do just that:

Dim iLoop For iLoop = LBound(aWeekDays) to UBound(aWeekDays) aWeekDays(iLoop) = Trim(aWeekDays(iLoop)) Next

Finally, we can print out the contents of the aWeekDays array if we'd like. Just need to iterate through each element in the array.

For iLoop = LBound(aWeekDays) to UBound(aWeekDays) Response.Write aWeekDays(iLoop) & "<BR>" Next

Well, that's all there is to it! I hope you learned something new! :)


  • Download the source for CreateArray.asp in text format
  • Download the source for ReceiveArray.asp in text format

  • Article Information
    Article Title: Passing Arrays from One ASP Page to Another, Part 2
    Article Author: Scott Mitchell
    Published Date: Tuesday, October 19, 1999
    Article URL:

    Copyright 2017 QuinStreet Inc. All Rights Reserved.
    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers