I declare an array on one form that i'd like to use on another form.
I declare it public in the declarations area and edit it later within a Private sub. However, when i reference it from another form it's as if i haven't editted it at all and it is only grabbing the initial declaration. Since i'm certain that i'm not being very clear, i've included an example of what i mean below:
Now let's say on another form that is a child of this one I try to use this array. I'll do something like:
OR
In both cases i get an error that basically complains because it is only looking at the line 'Public Array() As Integer'
If i change it to something like 'Public Array(1) As Integer' isn't helpful either.
What can i do to make my changes stick?
I declare it public in the declarations area and edit it later within a Private sub. However, when i reference it from another form it's as if i haven't editted it at all and it is only grabbing the initial declaration. Since i'm certain that i'm not being very clear, i've included an example of what i mean below:
VB.NET:
Public Class form1
Public Array() As Integer
Private Sub button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button.click
Redim Array(1)
Array(0) = 5
Array(1) = 2
End Sub
End Class
Now let's say on another form that is a child of this one I try to use this array. I'll do something like:
VB.NET:
Form1.array(0)
OR
VB.NET:
UBound(Form1.array,1)
In both cases i get an error that basically complains because it is only looking at the line 'Public Array() As Integer'
If i change it to something like 'Public Array(1) As Integer' isn't helpful either.
What can i do to make my changes stick?
Last edited: