GG asked ... Fix food processor motor?    |    T asked ... How do I turn the delay off on Electrolux DX302 dishwasher?    |    Helen asked ... How can I mend my Kenwood Gourmet FP505?    |    Roy Turner asked ... Kohlangaz Gosford HE fire?    |    Peter asked ... How can I mend a Powerwasher PRO PRO1800PWE?    |    Click here to ask your question

How can I change the label.text value from another Form in VB.NET?

Could someone post an example showing how to change a label's text on one form, when a button is clicked on another form. (I know VB6, but I'm struggling with the basics in VB.NET)

Please keep it simple. I'm trying to understand how to address a control on one form from another form.

Thanks.
Jim, November 2003
how can i change the label.text to another label in the same form by click a button in the same form

Kelly, February 2006
This is the way I do it.

Add a module to yout project and add this line .....
Public formMain As _formMain
..... formMain is the name of the form concerned.

Also in the module add this Sub .....
Sub main()
formMain = New _formMain()
formMain.ShowDialog()
End Sub

You will need to change your project's properties so that Sub main is called when the application is started.

Now that formMain has been started as an instance, you can address it from another form or module. (Eg, formMain.label1.text="this works")

Noel, February 2004