'How to set control properties in Form from another Form - VB.net

I have 2 Forms, Form1 and Form2. They each contain 1 Label and 1 Button.

How can I change Button Properties to Enabled=False or true and Label text to Label2.text="Text_Label1_From_Form1" in Form2 via Form1..?

this is my code but nothing changed in Form2.

Dim FrmM As New Form2
FrmM.Show()
FrmM.Label2.Text = Me.Label1.Text
FrmM.Button2.Enabled = False

someone pls help..?? thanks.

EDIT :

I want to try to clarify my question.

I have 2 forms.

FORM1

Label1.Text = "Fantastic!"

button1

FORM2

Label2.text = ""

When I click on Button1 then Label2 is in Form2 be Label2.text = "Fantastic!"

This perhaps could clarify my question .. thanks



Solution 1:[1]

Well, if i get your question straight you want to change a label text in a form through another form. Well, this is the code you are using, button1 in form1 (if the label in form2 named "label2":

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
       Form2.label2.text = "Fantastic!" ' Change label2 text in form2 to "fantastic!"
    End Sub

Well, your code is alright and it's not wrong, but you might showed the form as form2 not as FrmW when you declare a variable as new form and edit it and want to show it you should write declaredvariable.show not form.show() Anyway, let's assume that you have two forms (Form1,Form2), And the label in form2 that you want to change called "label2" and you want to changed using form1 with a button, the only thing you will code inside is the button, you wont need anything else not any label in form1 nor coding in form2. So the code in form1 I just used to answer this question is:

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim frm As New Form2 ' Declaring frm as a deplicate of Form2
    frm.Show() ' Showing the frm (the deplicated version of Form2)
    frm.Label2.Text = "Fantastic!" 'Changing label2 text in frm to "Fantastic!"
    End Sub

you wont need to change any other control or anything to change label2 in form2, the only thing you will need is to code inside the button that will change label2 in form2. PS: I'm using VS2012, PS: you dont need to deplicate form2 you can just do it directly, just like in the first code. Regrads.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1