J
John Dann
In VB.Net I have a Form1 main form that instantiates various class
objects. I want to change eg the title text of Form1 from within one
or more of these classes.
The solution kindly suggested here was to add a constructor into my
subsidiary class's code as in
Public Class MyClass
Public Sub New(ByVal frm as Form1)
F1=frm
End Sub
..... etc
And then in Form1 to instantiate the class as :
Dim oMyClass as New MyClass(Me)
Then in the code inside MyClass I can say:
F1.Text = "New window title"
This works fine when MyClass is instantiated inside a procedure inside
Form1, but I now want to use the oMyClass object with module-level
scope and so need to instantiate it in the form's main declarations
section.
But this is giving an error presumably because the reference to Me
isn't valid until the form's own constructor has run.
Is thee a way around this please?
JGD
objects. I want to change eg the title text of Form1 from within one
or more of these classes.
The solution kindly suggested here was to add a constructor into my
subsidiary class's code as in
Public Class MyClass
Public Sub New(ByVal frm as Form1)
F1=frm
End Sub
..... etc
And then in Form1 to instantiate the class as :
Dim oMyClass as New MyClass(Me)
Then in the code inside MyClass I can say:
F1.Text = "New window title"
This works fine when MyClass is instantiated inside a procedure inside
Form1, but I now want to use the oMyClass object with module-level
scope and so need to instantiate it in the form's main declarations
section.
But this is giving an error presumably because the reference to Me
isn't valid until the form's own constructor has run.
Is thee a way around this please?
JGD