Click here to Skip to main content
12,295,791 members (34,674 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB VB.NET
how to add addhandler and addressof in vb.net
Posted 19-Nov-12 19:48pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Take a look at this. You can find what you're looking for in the solution provided by Sergey Alexandrovich.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160525.2 | Last Updated 20 Nov 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100