' Project FormEvents, source code file frmB.vb ' Illustrate some of the form events. ' Note that a non-startup form must ' be explicitly created as an object. Public Class frmB Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Friend WithEvents txtMsg As System.Windows.Forms.TextBox 'Required by the Windows Form Designer Private components As System.ComponentModel.Container 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Private Sub InitializeComponent() Me.txtMsg = New System.Windows.Forms.TextBox Me.SuspendLayout() ' 'txtMsg ' Me.txtMsg.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtMsg.Location = New System.Drawing.Point(24, 64) Me.txtMsg.Name = "txtMsg" Me.txtMsg.Size = New System.Drawing.Size(200, 26) Me.txtMsg.TabIndex = 1 Me.txtMsg.Text = "" ' 'frmB ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(248, 109) Me.Controls.Add(Me.txtMsg) Me.Name = "frmB" Me.Text = "frmB" Me.ResumeLayout(False) End Sub #End Region Private Sub frmB_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load MsgBox("Load Event for b") End Sub Private Sub frmB_Activated(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles MyBase.Activated txtMsg.Text = "Activated Event for b" End Sub Private Sub frmB_Deactivate(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles MyBase.Deactivate txtMsg.Text = "Deactivate Event for b" End Sub Private Sub frmB_Closed(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles MyBase.Closed MsgBox("Closed Event for b") End Sub Private Sub frmB_Closing(ByVal sender As Object, _ ByVal e As System.ComponentModel.CancelEventArgs) _ Handles MyBase.Closing MsgBox("Closing Event for b") ' Don't actually close form. Hide it instead. e.Cancel = True Me.Hide() End Sub End Class