' Project Password Public Class frmMain Inherits System.Windows.Forms.Form Public Shared passwordAccepted As Boolean Public loginForm As frmLogin Public secretForm As frmSecret #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 '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. Friend WithEvents btnShowMsg As System.Windows.Forms.Button Friend WithEvents btnLogin As System.Windows.Forms.Button Private Sub InitializeComponent() Me.btnShowMsg = New System.Windows.Forms.Button Me.btnLogin = New System.Windows.Forms.Button Me.SuspendLayout() ' 'btnShowMsg ' Me.btnShowMsg.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.btnShowMsg.Location = New System.Drawing.Point(16, 56) Me.btnShowMsg.Name = "btnShowMsg" Me.btnShowMsg.Size = New System.Drawing.Size(200, 32) Me.btnShowMsg.TabIndex = 0 Me.btnShowMsg.Text = "Show Secret Message" ' 'btnLogin ' Me.btnLogin.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.btnLogin.Location = New System.Drawing.Point(16, 8) Me.btnLogin.Name = "btnLogin" Me.btnLogin.Size = New System.Drawing.Size(200, 32) Me.btnLogin.TabIndex = 0 Me.btnLogin.Text = "Login" ' 'frmMain ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(232, 101) Me.Controls.Add(Me.btnShowMsg) Me.Controls.Add(Me.btnLogin) Me.Name = "frmMain" Me.Text = "Main Form" Me.ResumeLayout(False) End Sub #End Region Private Sub frmMain_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load passwordAccepted = False End Sub Private Sub btnLogin_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnLogin.Click If IsNothing(loginForm) Then loginForm = New frmLogin End If loginForm.ShowDialog() MsgBox(loginForm.txtPassword.Text) If loginForm.txtPassword.Text = "rainbow" Then PasswordAccepted = True End If End Sub Private Sub btnShowMsg_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnShowMsg.Click If IsNothing(secretForm) Then secretForm = New frmSecret End If secretForm.ShowDialog() End Sub End Class