I'm creating a feature for my software that bans the user for 10 minutes if he/she has failed to login thrice.

The problem is, I don't know how to code that.
I got ideas on how to do it but I don't know what predefined classes or functions to use.

Can you please teach me what classes or functions to use to code this feature?
I'm a complete beginner but I'm willing to learn so please help.

Thanks in advance!

You could declare some variables with class scope such as

Dim numFailed As Integer            'number of consecutive failed login attempts
Dim lastAttempt As Date             'date & time of last login attempt
Dim lastUser As String              'name of last user to try to login

In the form load event, initialize numFailed to 0 and lastUser to "". When the user tries to login, the logic would be as follows

Dim canLogin as Boolean = True

if currentUser = lastUser Then
    if numFailed = 3 Then
        if less than 10 minutes since lastAttempt Then
            canLogin = False
        end if
    end if
end if

if canLogin then
    if Login(currentUser) Then
        numFailed = 0
        numFailed += 1
    end if
    lastUser = currentUser
    lastAttempt = Now()
    MsgBox("please wait a few minutes and try again"
end if

Thanks for the reply!

Gonna try this. I'll keep you updated to what happens.

hello !
if you are using db with this application then make a table for example name tblLogingFail .now when ever you want to ban a user then insert data in that table fields name recID,UserID,Logindate , now after this set condition that if logintime difference is less then 10 min then dont allow user and if difference is more then 10 mint allow him to login.


commented: Thanks for gaving me hints. +1

The last poster (whose handle I can't spell this early before my coffee) is right. You'd have to preserve the data somehow in case the user just restarts the app. This could be through a database, file, or through My.Settings variables.


Ok, so here's what I have so far.
I created a simple restriction for the user if he/she fails to login thrice.

Here it is

Private Sub BanUser()

        txtEmployeeID.Text = ""

        txtPassword.Text = ""

        txtEmployeeID.Enabled = False

        txtPassword.Enabled = False

        btnLogin.Enabled = False

        MessageBox.Show("You are banned for 10 minutes because your failed login attempts is more than thrice!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)



    End Sub

But I don't know what functions or objects to use to compare the time
of the user's last attempt and the current time on the system.

I tried this code from your code above @Reverend Jim,

Dim lastAttempt As Date

lastAttempt = Now()

but it seems that its returning the date and not the time.
And one more thing, can you please, teach me how this My.Settings variables work
because I don't have a clue on how to use it properly to store the time settings on the time restriction.

Thanks in advance!

Thanks for the reply!

I'd check this out and post here.

Got this now.