Mega Code Archive

 
Categories / VB.Net Tutorial / GUI
 

Add button to a form

imports System imports System.Drawing imports System.Windows.Forms namespace WinForms   public class HelloWorld : inherits System.Windows.Forms.Form     Private WithEvents btn as Button     public sub New()             Text = "Hello World"       btn = new Button()       btn.Location = new Point(50,50)       btn.Text = "Goodbye"       Controls.Add(btn)     end sub     public shared sub Main()        Application.Run(new HelloWorld())     end sub     private sub btn_Click(ByVal sender as object,ByVal e as EventArgs) Handles btn.Click       Application.Exit()     end sub   end class end namespace