How it works is the user registers their details on one form which will append those details to the end of the 2 text files that are holding the data.
At the moment this hasn't been implemented so we're just doing this manually.
Anyway, after that the user can "login" inputting a user name and password into 2 text boxes and the program looks for those details in the text files that they just registered.
I want the programme to read this by using "readline" in 2 text files and comparing what they've written in the text box with the corresponding text file and then checking whether those 2 words are on corresponding lines in the different text files, and so ensuring the user has put in the right username and password.
As I have average knowledge of vb.net and reading and writing to text files is new to me, I haven't really been able to debug it properly. But I had one idea to get the program to add an integer value at the beginning of each line and then get the program just to read the first character of each line and check if that was the same. But then I realised It ended up not having anything to do with the text boxes and I didn't know how to compare line by line anyway so It was pretty much pointless, but I'll include it in the code anyway.
On the form side there's just 2 text boxes "txtUsername" and "txtPassword" and a button for logging in "btnLogin"
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim Usernamereader As String = "G:\Text1.txt"
Dim PasswordReader As String = "G:\Text2.txt"
Dim TextLineUser As String
Dim TextLinePass As String
Dim CountUser As Integer
Dim CountPass As Integer
Dim CharUser As Char
Dim CharPass As Char
If System.IO.File.Exists(Usernamereader) And System.IO.File.Exists(PasswordReader) = True Then
Dim objReaderUser As New System.IO.StreamReader(Usernamereader)
Dim objReaderPass As New System.IO.StreamReader(PasswordReader)
Do While objReaderUser.Peek() <> -1
CountUser = 0
For CountUser = 1 To 10
CountUser = CountUser + 1
TextLineUser = TextLineUser & CountUser - 1 & _
objReaderUser.ReadLine() & vbNewLine
Next
CharUser = GetChar(TextLineUser, 1)
Loop
Do While objReaderPass.Peek() <> -1
CountPass = 0
For CountPass = 1 To 10
CountPass = CountPass + 1
TextLinePass = TextLinePass & CountPass - 1 & _
objReaderPass.ReadLine() & vbNewLine
Next
CharPass = GetChar(TextLinePass, 1)
Loop
If txtUsername.Text = TextLineUser And txtPassword.Text = TextLinePass Then
MsgBox("you logged in!")
MsgBox(TextLineUser)
MsgBox(TextLinePass)
MsgBox(CountPass)
MsgBox(CountUser)
Else
MsgBox("not good")
MsgBox(TextLineUser)
MsgBox(TextLinePass)
MsgBox(CountPass)
MsgBox(CountUser)
End If
Else
MsgBox("file does not exist")
End If

New Topic/Question
Reply



MultiQuote






|