Solved

How do I create password/login file

Posted on 1998-10-22
2
138 Views
Last Modified: 2010-04-30
I'm new to Visual Basic and would like to know how to create a program that will allow a user three chances to enter a login+password. If login successful, then check password. If after three attempts login still invalid, then display a message.

I don't know much about Arrays, but I would like to use them to store 3 valid logins/passwords.

Hope somebody can help me out.
0
Comment
Question by:wdw1971
2 Comments
 
LVL 2

Accepted Solution

by:
Veroland earned 100 total points
ID: 1441093
create a form with 2 text boxes as and a commmand button. I named mine txtName and txtPassword. The command button is cmdSubmit.

Click on the password textbox and set the passwordchar property of the textbox to *.
Now use the following code and if the user enters a password it will be checked against a array holding 3 login names and passwords. If you want to load the Login Names and Passwords from a file or database let me know and I will post it for you. This exaple uses hard coded login names and passwords.

Option Explicit
Dim LoginPSW(3, 2) As String
Dim Counter As Integer
   

Private Sub cmdSubmit_Click()
    Dim I As Integer
    Dim Match As Boolean
       
    Match = False
    For I = 0 To UBound(LoginPSW)
        If txtName.Text = LoginPSW(I, 0) Then
            If txtPassword.Text = LoginPSW(I, 1) Then
                Match = True
            End If
        End If
    Next I
    If Match = False Then
        MsgBox "User Name not found or Inccorect password"
        Counter = Counter + 1
    End If
   
    If Match = False And Counter = 3 Then
        MsgBox "Program will Terminate"
        End
    End If
End Sub

Private Sub Form_Load()
    LoginPSW(0, 0) = "User1"
    LoginPSW(1, 0) = "User2"
    LoginPSW(2, 0) = "User3"
    LoginPSW(0, 1) = "Password"
    LoginPSW(1, 1) = "Voda"
    LoginPSW(2, 1) = "Earth"
    Counter = 0
   
End Sub

0
 

Author Comment

by:wdw1971
ID: 1441094
Many thanks for the help. It was very useful.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question