Sharing variable between forms

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

Guest

I have two forms and wish to share some information between them.

I declare the array as Shared in the fisrt class but cannot reference it in the second class.
code is:-
Public Class DataEntry1
Inherits System.Windows.Forms.Form
Shared deArray(10) As String

#Region " Windows Form Designer generated code "
…

Private Sub Yes_Click(ByVal sender As System.Object ......
deArray(6) = "Yes"
End Sub

Public Class DataEntry2
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "
…

Private Sub yes1_Click(ByVal sender As System.Object, ....
deArray(4) = "Maybe"


End Sub
 
You have to qualify shared member with class name:

DataEntry1.deArray(...)

when accessing it from non-declaring classes

HTH
Alex
 
you can add a code module and declare those variables Public
or pass params ByVal
 
Back
Top