Addhandler with parameter ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter Stojkovic

    #1

    Addhandler with parameter ?

    Is it possible to add a handler , and the function to add has a parameter ?

    Or MUST the function have NO parameters ?


    Thanks
    Peter


  • Patrice

    #2
    Re: Addhandler with parameter ?

    Not sure what you mean. Keep in mind that when using addhandler, you just
    tell which method to call. You don't perform an actual call. This is why you
    never have to specify which parameters to use in this context.

    If this is not the problem, your best bet is to just show us directly what
    you tried so that we can understand the problem you have...
    --
    Patrice

    "Peter Stojkovic" <dsa@gmx.net> a écrit dans le message de news:
    Os%23NznTZGHA.4 884@TK2MSFTNGP0 2.phx.gbl...[color=blue]
    > Is it possible to add a handler , and the function to add has a parameter
    > ?
    >
    > Or MUST the function have NO parameters ?
    >
    >
    > Thanks
    > Peter
    >[/color]


    Comment

    • Cerebrus

      #3
      Re: Addhandler with parameter ?

      To add to what Patrice already explained, here is some sample code :
      -------------------------------------
      AddHandler Button1.Click, AddressOf ClickHandler
      AddHandler Button2.Click, AddressOf ClickHandler

      Private Sub ClickHandler (ByVal sender As System.Object, e As _
      System.EventArg s)
      ' Your code here.
      End Sub
      -------------------------------------

      In VB.NET, Event Handlers are Subs, not Functions, so they can't return
      values. This however has no implication on whether they accept
      parameters or not. In my example, the EventHandler method takes 2
      parameters.

      HTH,

      Regards,

      Cerebrus.

      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: Addhandler with parameter ?

        "Peter Stojkovic" <dsa@gmx.net> schrieb:[color=blue]
        > Is it possible to add a handler , and the function to add has a parameter
        > ?[/color]

        No problem. You do not need to list the function's signature when adding it
        as a handler.

        --
        M S Herfried K. Wagner
        M V P <URL:http://dotnet.mvps.org/>
        V B <URL:http://classicvb.org/petition/>

        Comment

        Working...