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
if canLogin then
if Login(currentUser) Then
numFailed = 0
numFailed += 1
lastUser = currentUser
lastAttempt = Now()
MsgBox("please wait a few minutes and try again"
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.
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)
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.
**how to solve invalid keystore error in android studio here is error report----------------------->
here is error report--------> error:Error:java.lang.RuntimeException: com.android.ide.common.signing.KeytoolException: Failed to read key palash from store "D:\MyApplication3.idea\workspace.xml": Invalid keystore format ...