Sharing variable between forms

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
 
A

AlexS

You have to qualify shared member with class name:

DataEntry1.deArray(...)

when accessing it from non-declaring classes

HTH
Alex
 
H

Hal Rosser

you can add a code module and declare those variables Public
or pass params ByVal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top