Option Explicit On 
Option Strict On

Public Class frmPassword
  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 Label1 As System.Windows.Forms.Label
  Friend WithEvents txtPassword As System.Windows.Forms.TextBox
  Friend WithEvents btnValid As System.Windows.Forms.Button
  Friend WithEvents btnExit As System.Windows.Forms.Button

  '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.
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.Label1 = New System.Windows.Forms.Label()
    Me.btnValid = New System.Windows.Forms.Button()
    Me.txtPassword = New System.Windows.Forms.TextBox()
    Me.btnExit = New System.Windows.Forms.Button()
    Me.SuspendLayout()
    '
    'Label1
    '
    Me.Label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
    Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.Label1.Location = New System.Drawing.Point(16, 16)
    Me.Label1.Name = "Label1"
    Me.Label1.Size = New System.Drawing.Size(256, 32)
    Me.Label1.TabIndex = 0
    Me.Label1.Text = "Please Enter Your Password:"
    Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
    '
    'btnValid
    '
    Me.btnValid.Location = New System.Drawing.Point(56, 112)
    Me.btnValid.Name = "btnValid"
    Me.btnValid.TabIndex = 2
    Me.btnValid.Text = "&Validate"
    '
    'txtPassword
    '
    Me.txtPassword.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.txtPassword.Location = New System.Drawing.Point(56, 64)
    Me.txtPassword.Name = "txtPassword"
    Me.txtPassword.PasswordChar = ChrW(42)
    Me.txtPassword.Size = New System.Drawing.Size(176, 29)
    Me.txtPassword.TabIndex = 1
    Me.txtPassword.Tag = "kidware"
    Me.txtPassword.Text = ""
    '
    'btnExit
    '
    Me.btnExit.DialogResult = System.Windows.Forms.DialogResult.Cancel
    Me.btnExit.Location = New System.Drawing.Point(160, 112)
    Me.btnExit.Name = "btnExit"
    Me.btnExit.TabIndex = 3
    Me.btnExit.Text = "E&xit"
    '
    'frmPassword
    '
    Me.AcceptButton = Me.btnValid
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.CancelButton = Me.btnExit
    Me.ClientSize = New System.Drawing.Size(300, 157)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnExit, Me.btnValid, Me.txtPassword, Me.Label1})
    Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
    Me.Name = "frmPassword"
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
    Me.Text = "Password Validation"
    Me.ResumeLayout(False)

  End Sub

#End Region

  Private Sub btnValid_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnValid.Click
    'This procedure checks the input password
    Dim Response As DialogResult
    If txtPassword.Text = CStr(txtPassword.Tag) Then
      'If correct, display message box
      MessageBox.Show("You've passed security!", "Access Granted", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
    Else
      'If incorrect, give option to try again
      Response = MessageBox.Show("Incorrect password", "Access Denied", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error)
      If Response = DialogResult.Retry Then
        txtPassword.SelectionStart = 0
        txtPassword.SelectionLength = Len(txtPassword.Text)
      Else
        Me.Close()
      End If
    End If
    txtPassword.Focus()
  End Sub

  Private Sub frmPassword_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'make sure focus starts in text box
    txtPassword.Focus()
  End Sub

  Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
    Me.Close()
  End Sub
End Class
