Carol asked ... How to remove roller from lawnmower?    |    Ariana Orellana asked ... Code?    |    Lynnie asked ... BT Studio 4500 cordless telephone?    |    David Dawes asked ... How to recoil the starter spring - Champion R484TR?    |    peter high asked ... How can I set time on my Neff oven?    |    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