1 2 3 | imports System imports System.Drawing imports System.Windows.Forms |
1 2 3 4 5 6 7 8 9 10 | 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 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 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 |
沒有留言:
張貼留言