0

Private Sub Button_Click() Handles Button1.Click, Button2.Click, Button3.Click
MsgBox()
End Sub


Can anyone say me how can we print that which button is clicked?????

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Reverend Jim
0

Private Sub Button_Click() Handles Button1.Click, Button2.Click, Button3.Click
MsgBox()
End Sub

Can anyone tell me how can we print that which button is clicked?????

The Click event is an EventHandler, which takes two parameters, the first of which is the object that caused the event--in this case, it's one of your buttons. Then you can use something like the button's Name property to display which one it is.

Edited by Reverend Jim: Fixed formatting

1

In the button click handler you can identify the button either by name or by label text (the label text is probably more informative depending on how you name your controls)

Dim button As Button = DirectCast(sender, Button)
MsgBox(button.Text & " " & button.Name)
Votes + Comments
hey thanx dud...
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.