0% found this document useful (0 votes)
86 views

Exercise 9

This document contains code for a login form. It checks the username and password entered against predefined credentials. If correct, it welcomes the user. If incorrect, it tracks the number of login attempts and alerts the user if they exceed 3 attempts, at which point it closes the form.

Uploaded by

api-310300017
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views

Exercise 9

This document contains code for a login form. It checks the username and password entered against predefined credentials. If correct, it welcomes the user. If incorrect, it tracks the number of login attempts and alerts the user if they exceed 3 attempts, at which point it closes the form.

Uploaded by

api-310300017
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Public Class Form1

Dim loginattempts As Integer


Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnCancel.Click
Close()
End Sub
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnOK.Click
If txtID.Text = "Jacob" Or "school" And txtPassword.Text = "aguynamedjacob" Then
MessageBox.Show("Welcome Jacob!", "Welcome")
txtID.Clear()
txtPassword.Clear()
ElseIf txtID.Text <> "Jacob" And txtPassword.Text <> "aguynamedjacob" Then
MessageBox.Show("Incorrect ID and Password", "Error!")
txtID.Clear()
txtPassword.Clear()
loginattempts += 1
ElseIf txtID.Text <> "Jacob" And txtPassword.Text = "aguynamedjacob" Then
MessageBox.Show("Incorrect ID", "Error")
txtID.Clear()
loginattempts += 1
ElseIf txtID.Text = "Jacob" And txtPassword.Text <> "aguynamedjacob" Then
MessageBox.Show("Incorrect Password", "Error")
txtPassword.Clear()
loginattempts += 1
End If
If loginattempts = 3 Then
MessageBox.Show("Sorry, Access denied", "Error")
Close()
End If
End Sub
End Class

You might also like