Scoping problem it seems...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

H

I have created an ASP web application in visual studio and am trying to do the following (apparently) simple thing, without success. Can anyone help

Firstly, within the class, but outwith any subs, I have declared the following array:
Dim max As Double() = New Double(179) {

I then populate this array in a sub in response to a user click, as follows:
Private Sub cmdSimulation_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSimulation.Clic

Dim i As Intege
max = ao.arrayMaximum(revdArray) 'revd Array was previously created in this sub (I have just omitted the code here for conciseness)

For i = 0 To max.GetUpperBound(0
txtTreatment.Text &= max(i) & "
Nex
txtTreatment.Text &= vbCrL
End Su

This works fine, and prints out the appropriate values in the text box. When I come to referencing this array (max) in another sub, however, it doesn't seem to know about it, and it prints out all zeros. The following is the code in the other sub:
Private Sub createLineGraph(
Dim i as intege

For i = 0 To max.GetUpperBound(0
txtTreatment.Text &= max(i) & "
Nex
end su

Any help would be appreciated.
 
Hi DC,

That sub that printsout is that in the same visit from the page to the
server as the loading fo the array

asp.net is stateless. It means that all values are destroyed when the page
is sended back to the client if you do not save them in by instance a
viewstate or a session.

I hope this helps?

Cor
 
Back
Top