Solved

How do I create password/login file

Posted on 1998-10-22
2
140 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

740 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