Link to home
Start Free TrialLog in
Avatar of mracuraintegra
mracuraintegra

asked on

How to incorporate a password into my program

Hey, I have a fairly simple question:
I have a program that runs batch files that change the registry; you click the 'Proxy on' (Command1) and it sets your proxy to a filtered server - you click 'Proxy Off' (Command2) and you no longer use that server. I have a TextBox (Text1).
I would like to know an easy way when you click each button to check and see if the password has been entered into the textbox. If so, then it goes ahead and runs the Shell ("c:\blahblahblah.bat"), but if the password is incorrect it does not run that line and pops a message up that informs me that the password is wrong. Any ideas?
ASKER CERTIFIED SOLUTION
Avatar of TigerZhao
TigerZhao

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You have three options to this problem:
1. You have to store a password in Windows Registry and then retrieve it from there.

2. You can use a database like Access or SQL server to store a password and retrieve when required.

3. You can hard code a password in the VB form itself and check it from there.

Here is an example for hardcoded password:

Dim strPassword as String

Sub Form_Load()
   strPassword="XYZ"
Exit Sub

Sub Command1_Click()
  If text1="" then
    Msgbox "Please enter a Password"
    text1.setfocus
  else
    if text1<>strPassword then
      Msgbox "Password not correct"
      text1.setfocus
    else
      msgbox "Password Accepted"
    end if
  end if
Exit Sub
Avatar of mracuraintegra
mracuraintegra

ASKER

Direct and to the point. I now have a compiled program and it's ready to use. EXACTLY WHAT I NEEDED!