|
-
Nov 24th, 1999, 04:24 PM
#2
Hyperactive Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|