last pressed button name

F

fixertool

Let's say I have this:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
' some code here
End Sub

I need the name of the button (here is "Button1") in a string
variable, when I click this button.
But I couldn't find the way.
Any idea?
Thanks in advance
 
T

Tom Shelton

Let's say I have this:

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click

Dim b As Button = DirectCast(sender, Button)
MessageBox.Show(b.Name)

End Sub
 

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

Top