Results 1 to 6 of 6

Thread: user name and password thing.

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    5

    Post

    the first time a person open my program. it will ask them to add a name the will and then it will ask for a password.next time they open the program there name will be in a list box and it will ask for the password. how do i do this.

  2. #2
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    New Jersey
    Posts
    334

    Post

    Hi! This probably isn't a very good way to do it but you can try. First of all, make two text files (for this example, I'm assuming they're in C:\Windows).
    Name one of them Start.txt, and the other User.txt. Then create an extra form for the password and username. Call it frmUser. On that form, place two textboxes (txtName and txtPassword) and a command button. Then place this code into the Form_Load event of your main form (NOT the password/name form). I'm assuming that it's called Form1:

    Dim startNum
    Open "C:\Windows\Start.txt" For Input As #1
    Do While Not EOF(1)
    Input #1, startNum
    Loop
    Close #1
    Me.Hide
    frmUser.Show

    Then place this code in the Click event of the Command Button on frmUser:

    Dim usrName As String
    Dim Password As String
    If startNum = 0 Then
    Open "C:\Windows\User.txt" For Output As #2
    Write #2, txtName.Text, txtPassword.Text
    Close #2
    startNum = 1
    Open "C:\Windows\Start.txt" For Output As #1
    Write #1, startNum
    Close #1
    End If
    If startNum = 1 Then
    Open "C:\Windows\User.txt" For Input As #2
    Do While Not EOF(2)
    Input #2, usrName, Password
    Loop
    Close #1
    If txtName.Text = usrName And txtPassword = Password Then
    Form1.Show
    Me.Hide
    Else
    MsgBox "Wrong Info"
    End If
    End If

    Now the last thing you need to do is open Start.txt nad type in 0 (zero). That's it. Any time you want the user to change his name/password, set startNum = 0 and then write StartNum to Start.txt. I tried the code but it displays the other form even with the wrong password/name. It has something to do with the IF THEN statement. Try to figure out how to fix it. If you can't, then e-mail me at:

    [email protected]

    Otherwise, good luck!

    Alexander McAndrew
    VB Zone http://gsenterprise.server101.com

  3. #3
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    New Jersey
    Posts
    334

    Post

    I just found one mistake (not too important). Where it says Close #1 near the bottom, change that to Close #2. Good luck!

    Alexander McAndrew
    VB Zone http://gsenterprise.server101.com

  4. #4
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845

    Post

    If possible it would be nicer using a database to hold password/username pairs.

    You can then easily populate your list and check the password using SQL


    ------------------
    Mark Sreeves
    Analyst Programmer

    [email protected]
    A BMW Group Company

  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    5

    Post

    that not what i wanted and that does not work.

  6. #6
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    New Jersey
    Posts
    334

    Post

    Sory, I guess I didn't read the question properly. You could be a little bit friendlier though. If you want, I can still help you.

    ------------------
    Regards,
    Alexander McAndrew
    VB Zone
    http://gsenterprise.server101.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width