Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do I create password/login file

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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.
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…
Suggested Courses

721 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