Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21842

Looping through a textfile for a login system.

$
0
0
Hi, im a student making a project for my computing coursework. The project is an afterschool register system.
Im having a little trouble with the login system, I have got it to work, as in, I can comapre strings stored in the text file (the account file where everyones login details are stored) with the textboxes where people enter their login details, and enter the system based on these comparisons if they are true.
But, my code does not seem to loop through the text file properly, it misses out the first record/ does not read the first record.
Can someone please help me with this?

Here is the code:

Code:


Private Sub CmdLogin_Click()

Dim isFound As Boolean
Dim AccountInfo As String
Dim AccountArray() As String
Dim Num As Integer

AccountFile = App.Path & "\Accounts.txt"
Open AccountFile For Input As #1


Do While Not EOF(1)

isFound = False

      Line Input #1, AccountInfo
     
        AccountArray = Split(AccountInfo, ";")

            If RTrim(AccountArray(0)) = TxtUsernameBox.Text And RTrim(AccountArray(1)) = TxtPasswordBox.Text Then
                         
                isFound = True
                                               
                End If
      Loop
       
Close #1

            If isFound = True Then
               
                FrmHomepage.TxtHistory.Text = "FrmLoginScreen"
               
                FrmHomepage.TxtUsernameBox.Text = TxtUsernameBox.Text
                FrmHomepage.TxtUsername.Text = TxtUsernameBox.Text
               
                FrmHomepage.Show
                FrmLoginScreen.Hide
               
                Else
               
                TxtErrorMsgBox = "Invalid Username/Passoword combination"
                       
            End If
           
End Sub

Any help would be greatly appreciated, thanks.

Viewing all articles
Browse latest Browse all 21842

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>