Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.IO
- Public Class ForgottenPassword 'forgotten password form
- Private Sub ForgottenPassword_Load(sender As Object, e As EventArgs) Handles MyBase.Load 'when form loads
- Me.CenterToScreen() 'centre form to screen
- Dim startupPath As String 'store the location the program is running
- startupPath = Application.StartupPath
- pbx_logo.ImageLocation = startupPath & "\PennardLibraryLogo.png" 'add the logo image location
- pbx_back.ImageLocation = startupPath & "\Arrow.png" 'add the back image location
- Me.BackColor = Color.FromArgb(163, 255, 166) 'Set the background to the standard light green
- End Sub
- Private Sub pbx_back_MouseHover(sender As Object, e As EventArgs) Handles pbx_back.MouseHover 'rollover image when hovered
- Dim startupPath As String 'store the location the program is running
- startupPath = Application.StartupPath
- pbx_back.ImageLocation = startupPath & "\ArrowRollover.png" 'change image to rollover
- End Sub
- Private Sub pbx_back_MouseLeave(sender As Object, e As EventArgs) Handles pbx_back.MouseLeave 'go back to normal when left
- Dim startupPath As String 'store the location the program is running
- startupPath = Application.StartupPath
- pbx_back.ImageLocation = startupPath & "\Arrow.png" 'change the image to the normal
- End Sub
- Private Sub pbx_back_Click(sender As Object, e As EventArgs) Handles pbx_back.Click
- Dim Login As New Login 'new instance of login form
- Login.Show() 'show new form
- Me.Close() 'close current form
- End Sub
- Private Sub txt_username_MouseClick(sender As Object, e As MouseEventArgs) Handles txt_username.MouseClick
- If txt_username.Text = "Username" Then 'Make text in the textbox that dissapears when clicked
- txt_username.Text = "" 'clear textbox
- End If
- End Sub
- Private Sub btn_forgottenPassword_Click(sender As Object, e As EventArgs) Handles btn_forgottenPassword.Click
- Dim encryption As New clsEncryption 'instantiate encryption class
- Dim found As Boolean = False 'has the record been found
- Dim record As String 'a record from the file
- Dim fields() As String 'the fields in the record
- Dim searchUsername As String 'the username being searched for
- searchUsername = txt_username.Text 'set the value
- Dim sr As New StreamReader("loginData.txt") 'a stream reader of the logindata file
- While sr.Peek() >= 0 'while there are records in the file
- record = encryption.decrypt(sr.ReadLine) 'decrypt the record
- fields = record.Split(",") 'split the record into fields
- If fields(1) = searchUsername Then 'if the username is stored in the record
- MsgBox("Your password is: " & fields(2)) 'searches for a username and the displays the password
- found = True 'record has been found
- End If
- End While
- If found = False Then 'if record wasnt found
- MsgBox("No account found with that username") 'notify user the record wasnt found
- End If
- sr.Close()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement