0

i have 2 forms in a project form1 and form2 in visual studio 2013. form2 consists 2 buttons (button1 and button2)

form1 has a timer event where form 2 will fire in certain cases. So i need code in Form1 to know if a button clicked in form2.

i tried these codes in form1 but not working:

if form2.button2_Click = true then
msgbox("Button 2 clicked")
end if

Please can someone help me with this and do the needfull.(i want to do this from form1 only)

2
  • 1
    A Button_click is an event - they fire when the user clicks and thats it, have the form with the button invoke a method on the other form telling it the button was clicked Commented Apr 5, 2017 at 19:32
  • Thank you Plutonix i got the method Commented Apr 5, 2017 at 20:16

1 Answer 1

1

in form2

Public Class Form2

Public Event SimulateForm1ButtonClick()

Private Sub MetroTile2_Click(ByVal sender As System.Object, ByVal e As   System.EventArgs) Handles MetroTile2.Click

    RaiseEvent SimulateForm1ButtonClick()


End Sub

And in Form1

Public Class Form1
Private WithEvents myform As New Form2


Private Sub frm2_SimulateForm1ButtonClick() Handles myform.SimulateForm1ButtonClick

msgbox("Sucecss!!!! called from form 2")
End Sub
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.