Click here for important information about

VB Login with a Loop

Microsoft Visual studio 6.0 enterprise e...
June 21, 2010 at 01:40:02
Specs: Windows XP
I want to create a log in form with User name and Password. If the user enter a wrong pass word 3 times, the program should End. Please Find the code for this.
Thank U

See More: VB Login with a Loop

June 21, 2010 at 08:29:23
Well, firstly it would help if you could explain what the program is intended to do, however im assuming you mean that when the application lauches it asks the user to enter credentials, if they credentials are incorrect after 3 failed attemnpts the applications should end.

Ok here is a very important question, where will the users crediantials (ie usernam and password) be stored???

i usually use an Access database to store this information, however if your application only had a hand full, maybe 10 users you could use a flat file such a as notepad and use some basic encryption to store the passwords, this is not the best solution, but with the lack of information you have provided we cannot really do much more.

Answer the above and we'll try and help.

Report •

June 23, 2010 at 22:07:01
Thank You for the quick reply.
My problem is, when the program runs, a login form should come with user name and password. They stored in an access Database. If the user enter an in correct password three times and try to login by clicking a button, the program should End automatically.

Report •

June 24, 2010 at 08:50:46
That is a fairly straight forward proceedure, some things i need to establish

1) what is the user enter his username eg smith123, incorrectly enters the password 2 times, then switches username to john123 should the counter reset for this user or should it continue to count from the previous? i would assume it will reset the counter?

2) do you know how to connect VB to access? i would use ADODB

now for the logic.

when the application launches you want the login screen to appear above the main window (main application) this is easily done by disabling the main window and enabling the login screen AND setting the login screen to be AlwaysOnTop (google it).

Now i would suggest that the login screen has a dropdown menu for the usernames, this can be pulled from the database so that you have an accurate list of all registered users.

Each time the user selects a username, set counter to 0, when a password is enetered check it if is correct, if yes then login, enable main window, close login screen. if incorrect, counter +1..

sub Drop_Down_change()
counter = 0
end sub

sub Login_button_Press()

do until counter =3
if password = incorrect then
counter = counter + 1
mainwindow.enabled = true
end if


end sub

this is a quick pseudo example of the logic, its basically how you will catch the incorrect password attempts and close the app.

Show us what you have done already and we can help you develop it further....... if you have nothing so far i will suggest you do as you will find that people will not help unless you show that you are trying to tackle the problem yourself first.

show us your code.



Report •
Related Solutions

Ask Question