How do I store Arrays as an Application Variable??

Results 1 to 2 of 2

Thread: How do I store Arrays as an Application Variable??

  1. #1
    John Hoegy Guest

    Default How do I store Arrays as an Application Variable??

    Hello,<BR><BR>I am trying to store an array as an Application variable. Any ideas?<BR><BR>Symptoms: It allows me to assign an array to an Application variable, and I can read pre-assigned values out. However, I cannot assign new values to the Application variable array.<BR><BR>Sample Code ("global.asa" file):<BR><BR>Sub Application_OnStart<BR>Dim aTest(100)<BR><BR> aTest(1) = "First"<BR> aTest(2) = "Second"<BR> aTest(3) = "Third"<BR><BR> Application("aTest") = aTest<BR><BR>End Sub<BR><BR>Sub Session_OnStart<BR><BR> &#039<BR> &#039 NOTE: This statement works. It should display the value on the page.<BR> &#039<BR> Response.Write "Application(""aTest"")(1) = *" & Application("aTest")(1) & "*<BR>"<BR><BR> &#039<BR> &#039 NOTE: This statement does not work. It doesn&#039t assign the new value. The<BR> &#039 original value will be displayed on the page.<BR> &#039<BR> Application("aTest")(1) = "Alpha"<BR> Response.Write "Application(""aTest"")(1) = *" & Application("aTest")(1) & "*<BR>"<BR><BR>End Sub

  2. #2
    Join Date
    Dec 1969

    Default RE: How do I store Arrays as an Application Variab

    Your on the right track. As you&#039ve shown you need to create an array first and then assign it to an application var. To access the array data once in the application var you need to create another normal var and assign the application var to it. Make sense? No, me neither! Here an example anyway :<BR><BR>&#039 Getting data into the Application array<BR>Dim MyArray(2)<BR><BR>MyArray(0) = 1<BR>MyArray(1) = 2<BR>MyArray(2) = 3<BR><BR>Application("MyArray") = MyArray<BR><BR>&#039 Getting data out of the Application Var<BR>Dim MyArray<BR><BR>MyArray = Applcation("MyArray")<BR><BR>Response.Write MyArray(0) & MyArray(1) & MyArray(2)<BR>&#039 Produces 123<BR><BR>Hope that helps<BR><BR>Pete<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