Application Variable as array?

Results 1 to 2 of 2

Thread: Application Variable as array?

  1. #1
    Join Date
    Dec 1969

    Default Application Variable as array?

    Help please.... I have made an array which is then assigned to an application variable which I&#039;ve defined as:<BR><BR>DIM temparray(400,9)<BR><BR>I then read from a small database 200 products into temparray and then I assign it to the application variable in my global.asa as such:<BR><BR>Application("products") = temparray<BR><BR>The problem is when I try to read:<BR><BR> lastrec = 0<BR> WHILE Application("products")(lastrec,1) &#060;&#062; "flag"<BR> lastrec = lastrec+1<BR> WEND<BR><BR>As soon as lastrec reaches 200 I get an error:<BR><BR>Subscript out of range: &#039;lastrec&#039;<BR><BR>If I remove 1 product from the database to make 199, the page works properly, as soon as 200 is reached, I get the error. Any suggestions?<BR><BR>Your help is very much appreciated.<BR><BR>Brett.<BR>

  2. #2
    Join Date
    Dec 1969

    Default See ASPFAQs...

    I dunno why this precise problem is happening, but you are doing a couple of horrible things in that code. Not the least of which is that you don&#039;t copy the array into a local VBS variable and, instead, keep hitting the Application collection by name. Have you any idea what a "hit" on your performance that is???<BR><BR>Anyway, look in the ASPFAQs, category ARRAYs, to see my suggestion for the right way to do this kind of stuff. I have never had it fail on something as minor as 200 elements.<BR><BR>Also: Note that you are really dimensioning your array bassackwards. It should have been (9,400) or some such. Reason: If you ever needed to expand it, you wouldn&#039;t be able to, as ReDim Preserve will only let you change the *last* dim of an array. Again, see the ASPFAQ entry.<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