Gonzalo Etse
Gonzalo Etse

Reputation: 153

Can't relate a part of the code to a button

I made a small and simple program (I'm a newbie), and they a proceded to do the code. The thing is, I don't know why, one part of the code isn't directed to a button as it is supposed to. They have the same name.
How do I direct it.
The code says:

Private Sub Boton1_Click(ByVal sender As Object, ByVal e As EventArgs)
    If lblcalculadora.Text = "0" Then
        lblcalculadora.Text = "1"
    Else
        lblcalculadora.Text = lblcalculadora.Text + "1"
    End If  

And Design page the button is called "Boton1_clicl". But when I doubleclick that button, it creates a new private sub called Boton1_click_1.
How can I connect the first part of the code with that button. I know it's a realy stupid matter, but I'm really stuck in here.

Upvotes: 2

Views: 50

Answers (2)

GJKH
GJKH

Reputation: 1725

You're missing Handles Boton1.Click

Private Sub Boton1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Boton1.Click
    If lblcalculadora.Text = "0" Then
        lblcalculadora.Text = "1"
    Else
        lblcalculadora.Text = lblcalculadora.Text + "1"
    End If  

Upvotes: 2

LarsTech
LarsTech

Reputation: 81620

You are missing the handler:

Private Sub Boton1_Click(sender As Object, e As EventArgs) Handles Boton1.Click

Upvotes: 2

Related Questions