Login form issue vb.net - vb.net

I'm creating a student data management system and I'm stuck on the login form.
I've created a sign up form where the details entered are saved in a text file (Users.txt).
I can't seem to figure out what the problem is in the login form code (pasted below); it doesn't seem to recognise any saved login usernames and passwords.
Please help.
Thanks.
Imports System.IO
Public Class Registration
Dim myfilewriter As StreamWriter
Dim myfilereader As StreamReader
Dim strMyFilename As String
Dim intNumofRecs As Integer
Dim temp As String
Structure Users
Dim intUserID As Integer
Dim strusername As String
Dim strpassword As String
End Structure
Dim UsersArray() As Users
Private Sub readindata()
Dim intCounter As Integer
strMyFilename = "Users.txt"
myfilereader = New StreamReader(strMyFilename)
intNumofRecs = myfilereader.ReadLine
ReDim Preserve UsersArray(intNumofRecs)
intCounter = 0
Do Until myfilereader.EndOfStream = True
intCounter = intCounter + 1
UsersArray(intCounter).intUserID = myfilereader.ReadLine()
UsersArray(intCounter).strusername = myfilereader.ReadLine()
UsersArray(intCounter).strpassword = myfilereader.ReadLine()
Loop
myfilereader.Close()
End Sub
Private Sub btnNewUser_Click(sender As Object, e As EventArgs) Handles btnNewUser.Click
Me.Hide()
Sign_Up.Show()
End Sub
Private Sub Registration_Load(sender As Object, e As EventArgs) Handles MyBase.Load
readindata()
End Sub
Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
Dim username As Boolean = False
Dim password As Boolean = False
Dim temp As String
myfilereader = System.IO.File.OpenText("Users.txt")
temp = myfilereader.ReadToEnd
myfilereader.Close()
If txtusername.Text = temp And txtpassword.Text = temp Then
username = True
password = True
Else
MsgBox("User not found")
End If
If username And password = True Then
txtusername.Text = ""
txtpassword.Text = ""
Me.Hide()
Dashboard.Show()
Else
End If
End Sub
End Class
and below is the code for the sign up form (how the text is saved to the users.txt file):
Public Sub SavetoTextFile()
Dim intCounter As Integer
readindata()
intNumofRecs = intNumofRecs + 1
ReDim Preserve UsersArray(intNumofRecs)
UsersArray(intNumofRecs).intUserID = intNumofRecs
UsersArray(intNumofRecs).strusername = txtUsername.Text
UsersArray(intNumofRecs).strpassword = txtPassword.Text
strMyFilename = "Users.txt"
myfilewriter = New StreamWriter(strMyFilename)
myfilewriter.WriteLine(intNumofRecs)
For intCounter = 1 To intNumofRecs
myfilewriter.WriteLine(UsersArray(intCounter).intUserID)
myfilewriter.WriteLine(UsersArray(intCounter).strusername)
myfilewriter.WriteLine(UsersArray(intCounter).strpassword)
Next
myfilewriter.Close()
End Sub
Private Sub btnSignUp_Click(sender As Object, e As EventArgs) Handles btnSignUp.Click
SavetoTextFile()
txtUsername.Text = ""
txtPassword.Text = ""
Me.Hide()
Registration.Show()
End Sub

Related

Data type long can not be converted

I have a problem with error which show me problem with long data type in this part of code:
If Not filename Then
Call Form15.Show()
TextBox1.Clear()
here is full code:
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Dim filename As String
Dim regCis = TextBox1.Text
filename = TextBox1.Text
Dim zakazCis As Double
Dim found As Boolean = False
found = True
If (Double.TryParse(TextBox2.Text, zakazCis)) Then
zakazCis = TextBox2.Text
Else
zakazCis = Nothing
End If
Dim basePath As String = "C:\_Montix a.s. - cloud\iMontix\Testy"
Dim filePath As String = IO.Path.Combine(basePath, filename & ".lbe")
'Napojeni tabulky
Dim table As DataTable = SdfDataSet.Tables("List1")
Me.Refresh()
'Vytvoreni dotazu
Dim expression As String
expression = ("[Čísla dílů] = '" & regCis & "'")
Dim foundRows() As DataRow
Me.PictureBox1.Invalidate()
Dim bla = "Label10"
'vykonani dotazu
foundRows = table.Select(expression)
If Not filename Then
Call Form15.Show()
TextBox1.Clear()
Else
If (foundRows(0)(2) = zakazCis) Then
'souhlasí regCis a zakcis
PictureBox1.Image = Image.FromFile("C:\_Montix a.s. - cloud\Visual Studio 2015\Projects\WindowsApplication17\WindowsApplication17\img\tick.png")
Label10.BackColor = Color.Green
Me.Controls(bla).Text = "SPRÁVNĚ"
fileprint.PrintThisfile(filePath)
Threading.Thread.Sleep(4000)
SendKeys.Send("{ENTER}")
TextBox2.Clear()
TextBox2.Select()
Button6.Hide()
PictureBox1.Hide()
Label10.Hide()
Else
'NEsouhlasí regCis a zakcis
PictureBox1.Image = Image.FromFile("C:\_Montix a.s. - cloud\Visual Studio 2015\Projects\WindowsApplication17\WindowsApplication17\img\cross.png")
Label10.BackColor = Color.Red
Form15.Show()
TextBox2.Clear()
TextBox2.Select()
End If
End If
End Sub
and here is code from form15
Public Class Form15
Private Sub Button11_Click(ByVal sender As Object, ByVal e As EventArgs)
Me.Hide()
End Sub
End Class
Do you known where is a problem?
You are using a string in a boolean expression. I guess, you might have added the string instead of the boolean by mistake. ('found' instead of 'filename')
If Not found Then
Call Form15.Show()
TextBox1.Clear()
Else

Log in form and store username/passwords in a file in aray structure

Currently my code is:
Public Structure
Dim Username as String
Dim Password as String
Dim Read() As String = IO.File.ReadAllLines("Passwords.txt")
Dim PassArray(Read.Length - 1) As Account
For i = 0 To PassArray.Length - 1
Dim line() = Split(Read(i), ","c)
PassArray(i).Username = line(0)
PassArray(i).password = line(1)
Next
If PassArray(0).Username = txtUsername.Text Then
If PassArray(1).password = txtPassword.Text Then
Form1.Show()
End If
Else
MsgBox("Wrong Username or Password!")
End If
I get an 'index outside the bounds of the array at PassArray(i).password = line(1)
I think i may have structured this wrong
the test file looks like:
Username
Password
Try this, If you doesn't work, let me know and i will do my best to help you out :)
Imports System.IO
Public Class Form1
Public Structure info
Dim Username As String
Dim Password As String
End Structure
Dim details As info
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If TextBox1.Text = details.Username And TextBox2.Text = details.Password Then
MessageBox.Show("Correct!")
Form2.Show()
Me.hide()
Else
MessageBox.Show("wrong")
Textbox1.Clear()
Textbox2.Clear()
End If
End Sub
Public Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim FILE = System.IO.File.ReadAllLines("Passwords.txt")
Dim myArray As String() = FILE
details.Username = myArray(0)
details.Password = myArray(1)
End Sub
End Class
You don't have to use the Structure, but I included it because it was a part of your question. Happy Coding!

Expired Page While Submitting payment

I am currently writing a bot to submit payments on a certain site. I wrote it all with simple form; grabs and fill works just fine, but the issue is when it goes through the first submit payment the web browser shows web page expired. I need help so that I do not get a webpage expired when I go forward into the payment.
Imports System.ComponentModel
Imports System.Security.Policy
Public Class Form1
Dim test As String
Dim useless As String
Dim usernme As String
Dim password As String
Dim first() As String
Dim fullname As String
Dim firstn As String
Dim lastn As String
Dim email As String
Dim full As String
Dim fulldir() As String
Dim stszip() As String
Dim adress As String
Dim city As String
Dim state As String
Dim zip As String
#Region "Page Loading Functions"
Private Property pageready As Boolean = False
Private Sub WaitForPageLoad()
AddHandler WebBrowser1.DocumentCompleted, New WebBrowserDocumentCompletedEventHandler(AddressOf PageWaiter)
While Not pageready
Application.DoEvents()
End While
pageready = False
End Sub
Private Sub PageWaiter(ByVal sender As Object, ByVal e As WebBrowserDocumentCompletedEventArgs)
If WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
pageready = True
RemoveHandler WebBrowser1.DocumentCompleted, New WebBrowserDocumentCompletedEventHandler(AddressOf PageWaiter)
End If
End Sub
#End Region
#Region "Page Loading Functions 2"
Private Property pageready2 As Boolean = False
Private Sub WaitForPageLoad2()
AddHandler WebBrowser2.DocumentCompleted, New WebBrowserDocumentCompletedEventHandler(AddressOf PageWaiter2)
While Not pageready
Application.DoEvents()
End While
pageready = False
End Sub
Private Sub PageWaiter2(ByVal sender As Object, ByVal e As WebBrowserDocumentCompletedEventArgs)
If WebBrowser2.ReadyState = WebBrowserReadyState.Complete Then
pageready = True
RemoveHandler WebBrowser2.DocumentCompleted, New WebBrowserDocumentCompletedEventHandler(AddressOf PageWaiter2)
End If
End Sub
#End Region
Dim url As String = ""
Dim pass As String
Private Sub WebBrowser1_NewWindow(sender As Object, e As CancelEventArgs) Handles WebBrowser1.NewWindow
e.Cancel = True
WebBrowser1.Navigate(WebBrowser1.StatusText)
End Sub
Private Sub WebBrowser1_DocumentCompleted(sender As System.Object, e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
Dim links As HtmlElementCollection = WebBrowser1.Document.Links
For Each var As HtmlElement In links
var.AttachEventHandler("onclick", AddressOf LinkClicked)
Next
End Sub
Private Sub LinkClicked(sender As Object, e As EventArgs)
Dim link As HtmlElement = WebBrowser1.Document.ActiveElement
url = link.GetAttribute("href")
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
WebBrowser2.ScriptErrorsSuppressed = True
WebBrowser2.Navigate("http://www.fakenamegenerator.com/")
WaitForPageLoad2()
Dim docum As HtmlElementCollection = WebBrowser2.Document.GetElementsByTagName("div")
Dim i As Integer = -1
For Each CurElement As HtmlElement In docum
If CurElement.GetAttribute("classname") = "address" Then
full = CurElement.InnerText
RichTextBox1.Text = full
End If
Next
docum = WebBrowser2.Document.GetElementsByTagName("span")
For Each CurElement2 As HtmlElement In docum
If CurElement2.GetAttribute("classname") = "value" Then
test = CurElement2.InnerText
If test.Contains("#") Then
email = test
End If
End If
Next
RichTextBox1.Text = RichTextBox1.Text + vbCrLf + email
fullname = RichTextBox1.Lines(0).ToString
first = Split(fullname, ".")
firstn = first(0)
lastn = first(1)
fulldir = Split(RichTextBox1.Lines(2).ToString, ",")
city = fulldir(0)
useless = fulldir(1)
stszip = Split(useless, " ")
state = stszip(1)
zip = stszip(2)
WebBrowser1.Document.GetElementById("username").SetAttribute("value", email)
WebBrowser1.Document.GetElementById("password").SetAttribute("value", pass)
Dim subm1 As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
For Each subm2 As HtmlElement In subm1
If subm2.GetAttribute("type") = "submit" Then
subm2.InvokeMember("click")
End If
Next
WaitForPageLoad()
MsgBox("lol")
WebBrowser1.Document.GetElementById("first-name").SetAttribute("value", firstn)
WebBrowser1.Document.GetElementById("last-name").SetAttribute("value", lastn)
Dim zipcodchk As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
For Each zipcodch As HtmlElement In zipcodchk
If zipcodch.GetAttribute("id") = "zip_code" Then
zipcodch.SetAttribute("value", zip)
End If
Next
For Each country As HtmlElement In zipcodchk
If country.GetAttribute("id") = "fake_country" Then
country.SetAttribute("value", "US")
End If
Next
Dim fullcc() As String
fullcc = Split(TextBox1.Text, "|")
WebBrowser1.Document.GetElementById("ccn").SetAttribute("value", fullcc(0))
WebBrowser1.Document.GetElementById("month").SetAttribute("value", fullcc(1))
WebBrowser1.Document.GetElementById("year").SetAttribute("value", fullcc(2))
WebBrowser1.Document.GetElementById("cvv2_code").SetAttribute("value", fullcc(3))
WebBrowser1.Document.GetElementById("continue3").InvokeMember("click")
WaitForPageLoad()
Dim subm3 As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
For Each subm4 As HtmlElement In subm3
If subm4.GetAttribute("id") = "continue3" Then
Exit Sub
End If
Next
WebBrowser1.Document.GetElementById("572").InvokeMember("click")
WaitForPageLoad()
WebBrowser1.Document.GetElementById("without-donation").InvokeMember("click")
WaitForPageLoad()
WebBrowser1.Document.GetElementById("checkbox1").InvokeMember("click")
WebBrowser1.Document.GetElementById("checkbox1").SetAttribute("value", "No")
Dim submit3 As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
For Each pressed As HtmlElement In submit3
If pressed.GetAttribute("type") = "submit" Then
pressed.InvokeMember("click")
End If
Next
WaitForPageLoad()
WebBrowser1.Document.GetElementById("continue-receipt").InvokeMember("click")
WaitForPageLoad()
If WebBrowser1.Url.ToString.Contains("home") Then
Label1.Text = Label1.Text + 1
End If
End Sub
Private Sub GenerateString()
Dim xCharArray() As Char = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray
Dim xNoArray() As Char = "0123456789".ToCharArray
Dim xGenerator As System.Random = New System.Random()
Dim xStr As String = String.Empty
While xStr.Length < 8
If xGenerator.Next(0, 2) = 0 Then
xStr &= xCharArray(xGenerator.Next(0, xCharArray.Length))
Else
xStr &= xNoArray(xGenerator.Next(0, xNoArray.Length))
End If
End While
pass = xStr
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
WebBrowser1.Document.GetElementById("first-name").SetAttribute("value", firstn)
WebBrowser1.Document.GetElementById("last-name").SetAttribute("value", lastn)
Dim zipcodchk As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
For Each zipcodch As HtmlElement In zipcodchk
If zipcodch.GetAttribute("id") = "zip_code" Then
zipcodch.SetAttribute("value", zip)
End If
Next
Dim fullcc() As String
fullcc = Split(TextBox1.Text, "|")
WebBrowser1.Document.GetElementById("ccn").SetAttribute("value", fullcc(0))
WebBrowser1.Document.GetElementById("month").SetAttribute("value", fullcc(1))
WebBrowser1.Document.GetElementById("year").SetAttribute("value", fullcc(2))
WebBrowser1.Document.GetElementById("cvv2_code").SetAttribute("value", fullcc(3))
WebBrowser1.Document.GetElementById("continue3").InvokeMember("click")
WaitForPageLoad()
Dim subm3 As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
For Each subm4 As HtmlElement In subm3
If subm4.GetAttribute("id") = "continue3" Then
Exit Sub
End If
Next
WebBrowser1.Document.GetElementById("572").InvokeMember("click")
WaitForPageLoad()
WebBrowser1.Document.GetElementById("without-donation").InvokeMember("click")
WaitForPageLoad()
WebBrowser1.Document.GetElementById("checkbox1").InvokeMember("click")
WebBrowser1.Document.GetElementById("checkbox1").SetAttribute("value", "No")
Dim submit3 As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
For Each pressed As HtmlElement In submit3
If pressed.GetAttribute("type") = "submit" Then
pressed.InvokeMember("click")
End If
Next
WaitForPageLoad()
WebBrowser1.Document.GetElementById("continue-receipt").InvokeMember("click")
WaitForPageLoad()
If WebBrowser1.Url.ToString.Contains("home") Then
Label1.Text = Label1.Text + 1
End If
End Sub
I left out the site im working on if it is the site then there is nothing i can do

Binary Reader and allowed characters

I have a problem.
Now program working like this:
Reading binary file bytes. &H1E and &H1F Allowed characters only :A123456789
If in file is B or C or D or E or F....... textbox1 = bad file
That's working. Now I want to add verification in &H10.
Allowed characters only 26
If other characters textbox1 = bad file
Imports System.IO
Imports System.IO.SeekOrigin
Public Class Form1
Dim charactersAllowed As String = "A123456789"
Dim swap As String = "26"
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim OFD As New OpenFileDialog
Dim fullFile() As Byte
With OFD
.Filter = "Binary files (*.bin)|*.bin"
End With
If OFD.ShowDialog = Windows.Forms.DialogResult.OK Then
fullFile = File.ReadAllBytes(OFD.FileName)
TextBox1.AppendText(fullFile(&H1E).ToString("X2") & " ")
TextBox1.AppendText(fullFile(&H1F).ToString("X2"))
TextBox4.AppendText(fullFile(&H10).ToString("X2"))
End If
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
Dim theText As String = TextBox1.Text
Dim Letter As String
Dim SelectionIndex As Integer = TextBox1.SelectionStart
Dim Change As Integer
For x As Integer = 0 To TextBox1.Text.Length - 1
Letter = TextBox1.Text.Substring(x, 1)
If charactersAllowed.Contains(Letter) = False Then
theText = theText.Replace(Letter, String.Empty)
Change = 1
End If
Next
TextBox1.Text = theText
TextBox1.Select(SelectionIndex - Change, 0)
End Sub
Private Sub TextBox4_TextChanged(sender As Object, e As EventArgs) Handles TextBox4.TextAlignChanged
Dim check As String = TextBox4.Text
Dim check2 As String
Dim check3 As Integer = TextBox4.SelectionStart
Dim check4 As Integer
For x As Integer = 0 To TextBox4.Text.Length - 1
check2 = TextBox4.Text.Substring(x, 1)
If swap.Contains(check2) = False Then
check = check.Replace(check2, String.Empty)
check4 = 1
End If
Next
TextBox1.Text = check
TextBox1.Select(check3 - check4, 0)
End Sub
Hard to decode, but an obvious approach is to prevent editing when the byte has the wrong value:
If OFD.ShowDialog = Windows.Forms.DialogResult.OK Then
fullFile = File.ReadAllBytes(OFD.FileName)
If fullFile(&H10) <> 26 Then
TextBox1.Text = "Bad file"
TextBox1.Enabled = False
TextBox4.Enabled = False
Else
TextBox1.Enabled = True
TextBox4.Enabled = True
'' etc...
End If
End If

Visual Basic - Object reference not set to an instance of an object

I'm receiving the following error in VB.Net.
"Object reference not set to an instance of an object"
It highlights "Next" at the end of the For Loop.
Any help would be great.
Imports System.IO
Public Class LoginForm
Dim Username() As String
Dim Password() As String
Dim Index As Integer
Public Function encrypt(ByVal data As String) As String
Dim answer As String = ""
Dim I As Integer
data = RTrim(data)
If Mid(data, 1, 1) <> Chr(0) Then
For I = 1 To Len(data)
answer = answer + Chr(Asc(Mid(data, I, 1)) Xor 23)
' Xor 23 is a simple encription cipher, a string can be
' encrypted or de-encrypted by the value following the Xor
'i.e. "23" '
Next I
End If
encrypt = answer
End Function
Private Sub LoginButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles LoginButton.Click
For Each I In Username
If UserNameTextBox.Text = Username(Index) Then
UserAdd.Show()
Me.Hide()
If PasswordTextBox.Text = Password(Index) Then
MessageBox.Show("Correct Password")
Else
MessageBox.Show("Invalid Password, Sorry")
End If
Else : MessageBox.Show("Invalid Username, Sorry")
End If
Next
End Sub
Public Sub ReadUsers()
Dim CurrentFileReader As StreamReader
Dim FileName, Line As String
Dim Delimiter As Char = ","
Dim Feild() As String
Dim Username() As String
Dim Password() As String
Dim Index As Integer
FileName = "C:\Computing\Projects\Login\Users.txt" 'location of
'user file
CurrentFileReader = New StreamReader(FileName)
Do Until CurrentFileReader.EndOfStream
Line = CurrentFileReader.ReadLine
If Line = Nothing Then
Exit Do
End If
ReDim Preserve Username(Index)
ReDim Preserve Password(Index)
Feild = Line.Split(Delimiter)
Username(Index) = encrypt(Feild(0))
Password(Index) = encrypt(Feild(1))
Loop
End Sub
Private Sub LoginForm_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles Me.Load
Call ReadUsers()
End Sub
End Class
Try replacing this code:
For Each I In Username
If UserNameTextBox.Text = Username(Index) Then
UserAdd.Show()
Me.Hide()
If PasswordTextBox.Text = Password(Index) Then
MessageBox.Show("Correct Password")
Else
MessageBox.Show("Invalid Password, Sorry")
End If
Else : MessageBox.Show("Invalid Username, Sorry")
End If
Next
with this code:
For Each I In Username
if Username(i) is not null then
If UserNameTextBox.Text = Username(Index) Then
UserAdd.Show()
Me.Hide()
If PasswordTextBox.Text = Password(Index) Then
MessageBox.Show("Correct Password")
Else
MessageBox.Show("Invalid Password, Sorry")
End If
Else : MessageBox.Show("Invalid Username, Sorry")
End If
else
....handle empty string
end if
Next
Which next are yout refering to?
In your second for, define that is I. That may not solve the problem, but this is definitly a better practive.
Is it possible that your data constains a 'null' character (chr(0))?
Mid will return null if it reaches the end of the string , but it doesn't look like this would happen to you.
Nevertheless, you might want to use String.Substring instead of mid. It's a function found with the string object.
I'll take a guess that it's the "For Each I In Username" loop inside LoginButton_Click that's causing you the problem?
I'm guessing at this loop as the type of variable "I" does not appear to be declared, so it would be type Object by default, matching the error "Object reference not set to an instance of an object".
Sub ReadUsers(), uses the locally defined variables for Username, Index and Password. Remove these lines from Sub ReadUsers().
Dim Username() As String
Dim Password() As String
Dim Index As Integer
At your class level.
A. Add this Imports to the top of the file:
Imports System.Collections.Generic
B. Change your String array definitions to List(of String)
Dim Username As List(Of String)
C. Then you no longer need to Redim. Just:
Username.add(encrypt(Feild(0)))
Loop on the count instead of item:
For i as integer = 0 to Username.length - 1
If UserNameTextBox.Text = Username(i) Then
...
Next
And finally, here's your code:
Imports System.IO
Imports System.Collections.Generic
Public Class LoginForm
' At the Class level Dim is equivalent to Private
Private Username As List(Of String)
Private Password As List(Of String)
Private Index As Integer
Public Function encrypt(ByVal data As String) As String
Dim answer As String = ""
Dim I As Integer
data = RTrim(data)
If Mid(data, 1, 1) <> Chr(0) Then
For I = 1 To Len(data)
answer = answer + Chr(Asc(Mid(data, I, 1)) Xor 23)
' Xor 23 is a simple encription cipher, a string can be
' encrypted or de-encrypted by the value following the Xor
'i.e. "23" '
Next I
End If
encrypt = answer
End Function
Private Sub LoginButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles LoginButton.Click
For i As Integer = 0 To Username.length - 1
If UserNameTextBox.Text = Username(i) Then
UserAdd.Show()
Me.Hide()
If PasswordTextBox.Text = Password(i) Then
MessageBox.Show("Correct Password")
Else
MessageBox.Show("Invalid Password, Sorry")
End If
Else : MessageBox.Show("Invalid Username, Sorry")
End If
Next
End Sub
Public Sub ReadUsers()
Dim CurrentFileReader As StreamReader
Dim FileName, Line As String
Dim Delimiter As Char = ","
Dim Feild() As String
FileName = "C:\Computing\Projects\Login\Users.txt" 'location of
'user file
CurrentFileReader = New StreamReader(FileName)
Do Until CurrentFileReader.EndOfStream
Line = CurrentFileReader.ReadLine
If Line = Nothing Then
Exit Do
End If
Feild = Line.Split(Delimiter)
Username.Add(encrypt(Feild(0)))
Password.add(encrypt(Feild(1)))
Loop
End Sub
Private Sub LoginForm_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles Me.Load
Call ReadUsers()
End Sub
End Class