Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

newbie question

Status
Not open for further replies.

jassrs

Technical User
Jul 10, 2003
56
0
0
US
I am trying to limit the number of times a user can attempt to logon to an application. example: they type in the incorrect name and password 3 times then the app shutsdown.

Can anyone help?
 
A simple method would be to use a counter. Increment the counter each time a login is attempted. When the counter reaches the desired number then shut down the app. Usually this is done where you verify the login.

Thanks and Good Luck!

zemp
 
Presumably you are displaying a form for them to enter UserID and password. Then just
Code:
   Dim Tries as Integer      ' In the declarations section

   Tries = 0                 ' In the Form_Load Event

   ' In the event where you are checking Userid & Password.
   If NOT ValidUserID() or NOT ValidPassWord() Then
      Tries = Tries + 1         
      If Tries > 3 then 
         MsgBox "You're Toast"
         End
      End If
   End If
 
declare either a public integer variable in a module, or a form level integer variable (in the General Declarations section of the code view)in your Login form, such as intCounter. Use this variable to count the number of times the user has incorrectly logged in. Each time the user enters incorrect login information, increment the counter by 1. After incrementing the counter, then test to see if it equals 3.

If it equals 3, simply send the user a message:
- msgbox "The program will now close."
and kill the app.
- End

It should work for you....hope it helps
 
Thanks for the help.... I figured it out with the examples ya'll gave....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top