Reusable Dynamic Arrays

Results 1 to 2 of 2

Thread: Reusable Dynamic Arrays

  1. #1
    David Sills Guest

    Default Reusable Dynamic Arrays

    While not a new programmer, I am new to ASP (VBScript). I am writing a page on which the user fills out three text boxes on a form, then submits the page back to itself to evaluate the results. Evaluation as such is not a problem. However, I want the user to be able to indefinitely continue the process, and to build up a dynamic array that is maintained from submit to submit. After one submission, for example, there might be three entries in the array. After another, there might be six, and so forth. I&#039ve tried a session-variable array without success (the syntax of ReDim Preserve on a session-level variable defeated me, I think), and local arrays seem to write over themselves on each submit (which makes sense). Any ideas? Thanks!<BR><BR>On a related question, if you declare a dynamic array and immediately ask for its UBound<BR><BR> Dim MyArray()<BR> MyInt = UBound(MyArray)<BR><BR>an array access error is generated. This makes (reluctantly) sense to me, although it seems they could have set the UBound as 0 in that situation. However, it makes no sense to me that when you do <BR><BR> Dim MyArray()<BR> Response.Write IsEmpty(MyArray)<BR><BR>the result is "False" (!). There must be some logic to it, but how can you find out that a dynamic array has not yet been redimensioned to any particular size?<BR>

  2. #2
    Vivek Nama Guest

    Default RE: Reusable Dynamic Arrays

    Dim MyArray()<BR>ReDim MyArray(0) &#039 force it<BR>Now if unintialised MyArray<BR>Response.Write IsEmpty(MyArray) =&#062; true <BR>for MyArray(0)="value"<BR>Response.Write IsEmpty(MyArray) =&#062; false<BR><BR><BR>

Posting Permissions

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