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.
 
Back
Top