From: Salad on
Steve Thackery wrote:

>
> "Salad" <salad(a)oilandvinegar.com> wrote in message
> news:SqidnX3XkNehulrWnZ2dnUVZ_gydnZ2d(a)earthlink.com...
>
>> So how does one call code contained in another button?
>
>
> May I offer another take on this? Forgive me if I've misunderstood, but
> your initial requirement can be met very simply by using the Events list
> in the Properties pane when Button 2 is selected. Use the dropdown list
> next to 'Click' and select 'Button1_Click'.
>
> Thus both buttons are handled by the same code.
>
> Now you can test "Sender". Here is a really braindead example (without
> even an 'else' in it):
>
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click, Button2.Click
>
> If sender Is Button1 Then
> Label1.Text = "button 1"
> End If
>
> If sender Is Button2 Then
> Label1.Text = "button 2"
> End If
>
> End Sub
>
>
> This is much like has already been posted, but I wanted to show you how
> simple it is to "borrow" another button's event handler.
>
> Is this of any help?
>
> Steve

I knew about the Handles Button1.Click, Button2.Click method. However,
I did not know about the If sender Is Button1 Then validation. I like that.