Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to add addhandler and addressof in vb.net
Posted

Take a look at this. You can find what you're looking for in the solution provided by Sergey Alexandrovich.
 
Share this answer
 
imports System
imports System.Drawing
imports System.Windows.Forms

public class AddressOfEvent : inherits System.Windows.Forms.Form

  Private WithEvents btn as Button

  public sub New()
    btn = new Button()
    btn.Location = new Point(50,50)
    btn.Text = "Test"

    Controls.Add(btn)
        AddHandler btn.Click, AddressOf btn_Click
  end sub

  public shared sub Main() 
    Application.Run(new AddressOfEvent())
  end sub

  private sub btn_Click(ByVal sender as object, _
      ByVal e as EventArgs)
    MessageBox.Show("btn_Click method","Events Demonstration")
  end sub

  private sub btn_ClickHandles(ByVal sender as object, _
      ByVal e as EventArgs) _
      Handles btn.Click
    MessageBox.Show("btn_ClickHandles method","Events Demonstration")
  end sub

end class
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900