2

I have a little problem calling the button1_click event of form1 from my form2.

When I call form1.button1_click() it gives me an error saying:

Argument not specified for parameter 'e'.

How can I fix this?

2 Answers 2

3

Assuming WinForms, try using this:

form1.button1_click(Nothing, Nothing)

or

form1.button1_click(form1.button1, EventArgs.Empty)

The error means the procedure you are trying to run has parameters, but you left them out in your call. The click event is looking for two parameters, sender As Object and e As EventArgs.

Sign up to request clarification or add additional context in comments.

Comments

2

You may also wish to try this:

form1.button1.PerformClick()

1 Comment

Looks like it works even if button1_click is a private method!

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.