You are on page 1of 1

Exercise #9

Public Class Form1


Dim Denied As Double

Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Button2.Click
Application.Exit()
End Sub

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Button1.Click
If TextBox1.Text = "Username" And TextBox2.Text = "Password" Then
MessageBox.Show("The ID and Password are correct.", "",
MessageBoxButtons.OK)
Application.Exit()

ElseIf TextBox1.Text = "Username" And TextBox2.Text <> "Password" Then


MessageBox.Show("The ID is correct but the password is incorrect.", "",
MessageBoxButtons.OK)
Denied = Denied + 1
TextBox1.Text = ""

ElseIf TextBox1.Text <> "Username" And TextBox2.Text = "Password" Then


MessageBox.Show("The ID is incorrect but the password is correct.", "",
MessageBoxButtons.OK)
Denied = Denied + 1
TextBox2.Text = ""

ElseIf TextBox1.Text <> "Username" And TextBox2.Text <> "Password" Then


MessageBox.Show("The ID and the password are incorrect.", "",
MessageBoxButtons.OK)
Denied = Denied + 1
TextBox1.Text = ""
TextBox2.Text = ""
End If

If Denied = 3 Then
MessageBox.Show("Sorry... Access denied.", "",
MessageBoxButtons.OK)
Application.Exit()
End If
End Sub
End Class

You might also like