How can I tell what control called a Sub?

  • Thread starter Thread starter jm
  • Start date Start date
J

jm

I have two buttons that onclick call the same sub.

How can I use the Sender as Object and the e as EventArgs to tell
which of the two buttons actually called the Sub? Thank you for any
help.
 
jm said:
I have two buttons that onclick call the same sub.

How can I use the Sender as Object and the e as EventArgs to tell
which of the two buttons actually called the Sub? Thank you for any
help.

You can use the CommandArgument property of the buttons. Set the
CommandArgument to two different things for the two buttons, then in your
handler you can cast "sender" to a button and check the CommandArgument
property.

At least, that's one way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top