Delen via


'AddHandler' and 'RemoveHandler' methods must have exactly one parameter

A custom event declaration must have AddHandler or RemoveHandler declarations, each of which takes a single parameter of the delegate type specified by the custom event's As clause.

Error ID: BC31133

To correct this error

  • Remove the extra parameters from the parameter list, and change the parameter type to be the same as the delegate type specified by the custom event's As clause.

Example

This example shows a custom event with the correct parameter types for the AddHandler and RemoveHandler declarations.

Custom Event Test As System.EventHandler
    AddHandler(ByVal value As System.EventHandler)
        ' Code for adding an event handler goes here. 
    End AddHandler 

    RemoveHandler(ByVal value As System.EventHandler)
        ' Code for removing an event handler goes here. 
    End RemoveHandler 

    RaiseEvent(ByVal sender As Object, ByVal e As EventArgs)
        ' Code for raising an event goes here. 
    End RaiseEvent 
End Event

See Also

Reference

Event Statement

AddHandler

RemoveHandler

Other Resources

Events in Visual Basic