2
Reply

Skip the same code for buttons [RESOLVED]

Antonio March

Antonio March

Sep 17 2010 5:50 AM
3.2k
I have several Windows Forms in my VB .NET application.
Most of them have a button called btnExit that has this event.

Public Class frmTest
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles btnExit.Click

        Me.Close()

    End Sub
End Class

I think this piece of code could removed from all the forms and substitute by a code that reflects the following way of reasoning

btnExit belongs to the Class of clsButtonsExit, and that class always handles the Me.Close () statement when clicked.... But, how is this implemented???

Another question: the underscore in the function declaration can't be removed in Visual Basic 2010 Express, it causes a Debug error. I thought underscores where no longer required in VB 2010 (althought I think it is a good practise to keep them )

thanks

Answers (2)