Global Arrays in Application_Start
My global.asax looks something like this:
<%@ Application Language="VB" %>
<script runat="server">
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application startup
Dim Par(4, 21)
Par(0, 0) = 4
Par(0, 1) = 4
Par(0, 2) = 3
Par(0, 3) = 4
Par(0, 4) = 3
Par(0, 5) = 5
... and so on and so forth, then
Application("Par") = Par ' Allocate application array
... and the other arrays look similar
End Sub
</script>
Okay, that seems to work fine, but, I don't seem to be able to actually reference the values in my Page_Load procedure. When I do something like this:
Par = Application("Par")
it whines that Par is not declared :mad: . Do I need to do something like this:
Dim myVar as String
myVar = Application("Par(0,0)").toString()
What I really want to do is reference Par in two for/next loops something like this:
Dim i, j as Integer
Dim myVar as String
myVar = Application("Par(i,j)").toString()
Maybe I'm just going about this in the wrong way or this isn't the place where I should be doing this. Ultimately, I'm going to set a variable.Text equal to the value in the array converted to a string. But, I want variable to be comprised of "Par" and the concatenation with i, converted to a string.
In other words, I want to do something like this:
Dim i, j as Integer
Dim myVar as String
For i = 0 to 3
For j = 1 to 21
myVar = "Par" & j.toString()
myVar.Text = Application("Par(i,j-1)").toString() :confused:
' the above line, I know, is VERY incorrect, but you get the idea
Next
Next
the line that's incorrect should execute as Par1.Text = whatever the value of Par(i, j) is, converted to a string. Par1 is a label on the page and I want to set the text value to the value in the array. I don't know how to do that yet, but I'm sure I'll figure it out.
Right now, I'm trying to determine why it won't let me access the application level arrays that I've declared in Application_Start. And just so you know, I'm coding this stuff using Visual Web Developer 2005 Express Edition, so it's using ASP.NET 2.0 (if that matters).
Any ideas on how to accomplish this or should I look to doing this another way?

