Open Ended Array? Can it be done?

Results 1 to 2 of 2

Thread: Open Ended Array? Can it be done?

  1. #1
    Join Date
    Dec 1969

    Default Open Ended Array? Can it be done?

    I have the following code, but would like to have the arrays(*) without a restriction on there size. Do you always have to predetermine the size of the array? Here is the code:<BR> Dim LinkCount<BR> LinkCount=Request.Form("LinkCount")<BR> Dim CountCheck<BR> CountCheck=1<BR><BR> Dim Descripts(*)<BR> Dim PageRefs(*)<BR> Dim Headings(*)<BR><BR> Do Until (CountCheck&#062;LinkCount)<BR> Descripts(CountCheck)= request.form("Description&#039" &CountCheck& "&#039")<BR> PageRefs(CountCheck)= request.form("PageRef&#039" &CountCheck& "&#039")<BR> Headings(CountCheck)= request.form("Description&#039" &CountCheck& "&#039")<BR> <BR> CountCheck=(CountCheck+1)<BR> Loop<BR><BR>Can someone please help soon, I have a horribly close deadline on this.<BR><BR>Cheers<BR><BR>Bryce

  2. #2
    Join Date
    Dec 1969

    Default RE: Open Ended Array? Can it be done?

    You can do this with the redim statement:<BR><BR>Dim LinkCount<BR>LinkCount=Request.Form("LinkCount")<B R>Dim CountCheck<BR>CountCheck=1<BR><BR>Dim Descripts() &#039 Dim w/o a number.. creates dynamic array<BR>Dim PageRefs()<BR>Dim Headings()<BR><BR>Redim Descripts(LinkCount) &#039 sets the initial number of elements<BR>Redim PageRefs(LinkCount)<BR>Redim Headings(LinkCount)<BR><BR>Do Until (CountCheck&#062;LinkCount)<BR>Descripts(CountChec k)= request.form("Description&#039" &CountCheck& "&#039")<BR>PageRefs(CountCheck)= request.form("PageRef&#039" &CountCheck& "&#039")<BR>Headings(CountCheck)= request.form("Description&#039" &CountCheck& "&#039")<BR><BR>CountCheck=(CountCheck+1)<BR>Loop< BR><BR>Redim Descripts(NewCount) &#039 changes the number of elements<BR>Redim Preserve PageRefs(NewCount) &#039 Use preserve to retain old data<BR>Redim Headings(NewCount)<BR><BR><BR>Notes:<BR>Try to use redim as infrequently as possible as it uses a fair of system resources. You can only change the number of elements in the last dimension of a multi-dimensional array. You can use the preserve keyword (as shown above) to retain data when you resize the array.<BR><BR>Hope that answers your questions.<BR>Grant

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts