Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do I create password/login file

Posted on 1998-10-22
2
Medium Priority
?
146 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 400 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

Independent Software Vendors: 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 While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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…
Suggested Courses

879 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