Question Handle button

ahhak1989

Member
Joined
Sep 18, 2009
Messages
5
Programming Experience
Beginner
I have added a button to my form from code because I'm linking a screen from other form, and in the linked form I've to add a back button. Now I success added a button in my form, but I cant handle the btnBack.Click
Anyone guide me please?
VB.NET:
Dim btnBack As New Button

Dim y As Integer = 340
        Dim x As Integer = 20
        btnBack.Text = "Back"
        btnBack.Top = y
        btnBack.Left = x

Private Sub btnBack_click(ByVal sender, ByVal e) Handles btnBack.Click
        MessageBox.Show("Your Button Work","Test", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
 
I found another way to add a button in another form to set is visible=False and when the new form loaded, the button set to visible=True. and using a handes button in another form.
 
I know you already have a solution that works, but you could declare the control using the WithEvents keyword too"
VB.NET:
Private WithEvents m_Button As Button

Load event
m_Button = New Button

Private Sub m_Button_Click (...) Handles m_Button.Click

End Sub
 
Back
Top