Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: 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
0 OriginalGriff 675
1 CPallini 320
2 Sergey Alexandrovich Kryukov 305
3 BillWoodruff 285
4 Peter Leow 255


Advertise | Privacy | Mobile
Web04 | 2.8.141029.1 | Last Updated 20 Nov 2012
Copyright © CodeProject, 1999-2014
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