Redim Preserve Dynamic array

Results 1 to 5 of 5

Thread: Redim Preserve Dynamic array

  1. #1
    Manoj Guest

    Default Redim Preserve Dynamic array

    Hi<BR><BR>I have a 2 dimensional array declared as <BR><BR>Dim Rptrow(55,0) as global . <BR><BR>Later in the function I am doing :<BR><BR>function AddRptRow<BR> dim ubnd<BR> ubnd = Ubound(RptRow, 2)<BR> ubnd = ubnd + 1<BR> redim preserve Rptrow(55, UBound(Rptrow, 2) + 1)<BR>&#039;redim preserve RptRow(55,ubnd)<BR> AddRptRow = ubnd<BR>End function<BR><BR>I am getting an error as 10Microsoft VBScript runtime errorThis array is fixed or temporarily locked . If i declare it as Rptrow(0,0) it gives me subscript out of range error. <BR><BR>Can anyone please help .i guess something is wrong with redim preserver statement.<BR>i will truelu appreciate any help<BR><BR>Thanks<BR>Manoj

  2. #2
    RDM Guest

    Default Redim multi-dimensional arrays...

    ...You can only adjust the "right" most dimension of a multi-dimensional array. I think you have your elements backwards in the declaration.<BR><BR>If it&#039;s at all possible, try setting your array to start with to include more elements than you ever "plan" to need. You&#039;ll find it&#039;s much faster than performing redim&#039;s again and again. At the end of the loop, perform one redim preserve to properly size the array.

  3. #3
    Manoj Guest

    Default RE: Redim multi-dimensional arrays...

    I guess i am adjusting my right most dimension of the arrya only .my array contains fixed first dimension as 55 and second dimension varies and upper bound is returned by this function. <BR>i am confused about the syntax .it returns errors even if i declare array as 55,0 or as 0,0 .<BR><BR>could u pl. show look at syntax of redim preserver ?<BR><BR>thanks in advance

  4. #4
    RDM Guest

    Default View Test Script-It Works...

    &#060;%<BR><BR> dim sArray()<BR><BR> redim sArray(55,2)<BR><BR> sArray(55,0) = "Robbe"<BR> sArray(55,1) = "Morris"<BR> sArray(55,2) = "Gartner"<BR> response.write sArray(55,0) & "<BR>"<BR> response.write sArray(55,1) & "<BR>"<BR> response.write sArray(55,2) & "<BR>"<BR> redim preserve sArray(55,10)<BR> response.write "<BR><BR>"<BR> response.write sArray(55,0) & "<BR>"<BR> response.write sArray(55,1) & "<BR>"<BR> response.write sArray(55,2) & "<BR>"<BR> sArray(55,3) = ""<BR> response.write sArray(55,3) & "<BR>"<BR><BR>%&#062;

  5. #5
    manoj Guest

    Default RE: View Test Script-It Works...

    thnax.code works!

Posting Permissions

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