I tried to initialize an array in a Public Sub, but then when I try to access the array's value from Button1 click event, it shows blank.
Thanks in advance.
A
VB.NET:
Public Class Form1
Public myArray()
Public Sub SimpleArray()
ReDim Preserve myArray(10)
For i = 0 To myArray.Length - 1
myArray(i) = i * 3
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'SimpleArray()
'Can I access the value of the myArray without calling the Sub?
ReDim Preserve myArray(10)
MessageBox.Show(myArray(4))
End Sub
End Class
Thanks in advance.
A