Dim formmain as Form some variable to hold the instance
pass in the form instance
Public Sub New(byval mainform as form1) get the variable that
contains the forms instance
MyBase.New
InitializeComponents()
formmain = mainform get the instance to a variable that
can be used in this throughout this class
End Sub
in some other sub
public sub DoSomething()
formmain.sometextbox.text = "some text" use the variable with
that instance to access the textbox on the form.
end sub
public string SomeText {
get {
return Textbox1.Text;
}
set {
Textbox1.Text = value;
}
}
MainForm.SomeText = "Hello there.";
string str = MainForm.SomeText;
Console.Writeline(str + "-" + MainForm.SomeText);
dim mainframe as mainframe
private sub button1_click(byval sender as system.object,byval e as system.eventargs)hangles button1.click
mainframe.text1.text = "HY"
me.close()
end sub