Im trying to search a text file and first find the user inputted name. Compare that to the text file, if it finds the name in the file, then check the password...compare...If all good than AccountOK() else Accountbad()
The code I have currently searches the text file for the user inputted "name"..if it finds the name in the textfile, then it says If Index of "name" is >0 Then check password....
If I just check for the "name" the code works fine, but if I add the passcheck code it then always returns Accountbad() Even if the user name and password are correct.... IS there a better way to search for the actual name in the textfile and not just if the index is >0...And then the same for the password...preferably MOVE one line down from the found user name and then check that line..My text file format is like this:::
Account 1
Name = JoeBob
Pass = whatup

My code so far is this:
Code:
Public Sub accountvalidation(ByVal name As String, ByVal pass As String)
        Dim path As String = Application.StartupPath & "\accounts.txt"
        Dim data As String, n As Integer, p As Integer
        accounts = New StreamReader(path)
        data = accounts.ReadToEnd
        n = data.IndexOf(name)
        If n > 0 Then
            p = data.IndexOf(pass)
            If p > 0 Then
                accountok()
            Else
                accountbad()
            End If
        Else : accountbad()
        End If

    End Sub
I know this is flawed...just can't figure out a better way to do this..Thanks in advance..