OK, I am creating a program where I have two forms, the login and main form. On the login form the user will be prompted to enter their account number and password. This info is read from a file. Upon a successful login the main form will pop up with options to perform from there. I got it to where it will continue to the main form, but it gives me a error message every time. I am thinking I have the validation in the wrong spot. I'm sure I am just forgetting something. Also I was wanting to perform some type of encryption so no one could just open up the txt file and see the passwords in plain-text, I am completely lost when it comes to ideas on this one. And finally, once the users has entered in an account number/password three time I want it to terminate the program.
[CODE=vbnet]Public Class frmLogin
'Error message, how can I get rid of it
'Encrypt password, read it backwards
Dim sr As IO.StreamReader
Dim Acctnumber, password As String
Private Sub frmBankATM_Load (ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
Me.Text = "RBD Bank Account Login"
End Sub
Sub OpenFile()
sr = IO.File.OpenTex t("customers.tx t")
End Sub
Sub CloseFile()
sr.Close()
End Sub
Private Sub btnSubmit_Click (ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnSubmit.Click
OpenFile()
Do While sr.Peek <> -1
Acctnumber = sr.ReadLine
password = sr.ReadLine
If txtaccount.Text = Acctnumber And txtpassword.Tex t = password Then
frmMainboard.Sh ow()
End If
Loop
OpenFile()
If sr.Peek <> -1 Then
MsgBox("The Account Number and/or Password Combination is Wrong", MsgBoxStyle.Cri tical, "Invalid Password")
Exit Sub
End If
CloseFile()
End Sub
End Class[/CODE]
[CODE=vbnet]Public Class frmLogin
'Error message, how can I get rid of it
'Encrypt password, read it backwards
Dim sr As IO.StreamReader
Dim Acctnumber, password As String
Private Sub frmBankATM_Load (ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
Me.Text = "RBD Bank Account Login"
End Sub
Sub OpenFile()
sr = IO.File.OpenTex t("customers.tx t")
End Sub
Sub CloseFile()
sr.Close()
End Sub
Private Sub btnSubmit_Click (ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnSubmit.Click
OpenFile()
Do While sr.Peek <> -1
Acctnumber = sr.ReadLine
password = sr.ReadLine
If txtaccount.Text = Acctnumber And txtpassword.Tex t = password Then
frmMainboard.Sh ow()
End If
Loop
OpenFile()
If sr.Peek <> -1 Then
MsgBox("The Account Number and/or Password Combination is Wrong", MsgBoxStyle.Cri tical, "Invalid Password")
Exit Sub
End If
CloseFile()
End Sub
End Class[/CODE]
Comment