How to use event handlers in


New member
Oct 1, 2004
Programming Experience
Anyone who knows abt how to use eventhandlers and 4 wht purposes in .net pls gve me some code samples or white papers demonstartes those areas.
We could probably help more if we knew what events you wanted to handle, but in .NET the basic format is:

Private Sub SubNameCanBeAnything(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonName.Click
   'Code here to handle the button click event
End Sub

Lets walk through the example:
1. Private means that it is only availalbe to the Class that it is in.
2. Sub means that it is a Subroutine
3. SubNameCanBeAnything is the sub name (can be anything, but it should be descriptive of what it does such as btnName_Click)
4. ByVal sender as System.Object is the first argument for all .NET event arguments
5. ByVal e as System.EventArgs is the second argument for all .NET event arguments (sometimes the as System.EventArgs needs to be a more specific Event Argument Typp)
6. Handles btnName.Click tells .NET what event this subroutine handles. Also one subroutine can handle more than just one event (eg: Handles btn1.Click, btn2.Click)

If you need more specific help, again please tell us what sort of event you are wanting to handle and we can answer with more specifics.