Hi Jimmy,
|| Public VariableName as Type
|| Form1.VariableName
That's fine in VB6 where Form1 is the actual Form. In VB.NET, Form1 is the
Type <only>.
If you had
Class Form1
Public Shared VariableName As SomeType
then
Form1.VariableName would access it correctly - it wouldn't however
belong to the <instance> of Form1 but to the Form1 Class - and hence all
instances of Form1.
This wouldn't, of course, be a problem if you will only have one - in fact
you could have all your variables Shared!
To access a Form's variables from another class (Form or otherwsie), you
need a reference to the actual instance. This can be done in several ways.
One is to store the reference to Form1 in its own Class as a Shared
variable. As noted above, this only works if there will be <only one>
instance.
Class Form1
Public Shared TheActualForm1 As Form1
Public Sub New
TheActualForm1 = Me
Class Foo
Sub Dibbly
Dim T As String = TheActualForm1.Text
Another method is to create a Module and store it there. (Note that Shared
is not needed as it's done for you behind the scenes)
Public Module GlobalStuff
Public TheActualForm1 As Form1
Class Form1
Public Sub New
TheActualForm1 = Me
Other methods involve passing a reference (ie. Me) from Form1 to the other
class.
Regards,
Fergus