Passwording a program

How do I code a VB program to ask for a login and password?  It should be the first form that loads when I execute my program.

Points will go up if you can provide code for this.
kevshAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kamallCommented:
Make a form with 2 text boxes and a command button with caption 'Login'.
Text1 is the username text box and Text2 is the password text box.

In the Command1 Click event enter this code:
MyLoginName = "lllll"
MyPassword = "ppppp"

If Text1="MyLoginName" and Text2="Mypassword" Then
    Form1.Show   'Your first form
Else
    Msgbox "Incorrect Login name or password"
    End
End If

Hope that helps.
Regards.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kamallCommented:
Sorry, there is a mistake in the code. It should be:
MyLoginName = "lllll"
MyPassword = "ppppp"

If Text1 = MyLoginName and Text2 = MyPassword Then
   Form1.Show   'Your first form
Else
   Msgbox "Incorrect Login name or password"
   End
End If
0
kamallCommented:
Also, if the login is correct, you must unload the login form by inserting the following line after the Form1.Show line:

Unload Me
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

v_iyengarCommented:
Have a module
in the module
sub main
  frmLogin.show
end





have  2 textbox and a button


on button click
check the value of the text box with the value stored in a
database
the password must not be hard coded

the password must be in database

you should also allow to change the password
if you hard code you can not give this feature



After checking if the password is correct the call the first form
of your Application
other wise unload the login form
0
KDivadCommented:
Don't forget to set the password box's "Password Character(?)" to something other than "". For standard purposes, set it to "*".
0
RandomTaskCommented:
Or just go to insert form and choose a login form, all code provided for you!
0
JuiletteCommented:
AS suggested, the code from Random Task is there for you...it's only short coming is the same as that of your proposed answer...you can't change the passwork because it is hard coded...one should have the ability to change passwords and as well it should eat the password if tried more than x times and failed...to prevent too many chances of breaking your password.
You need to write the password to a file and then open the file and compare your text box entry to the file. On change you open the file for output and just replace the old password with the new.For eating the password you just use a counter for each time the enter button was pressed and when it reaches your max you lock the textboxes and msg the user that the program is locked and can only be unlocked by administrator. Of course, you now have another page that the administrator only can call and it has the ability to overwite the file and unlock the text boxes etc.

That should about do it...
good luck...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.