Advertisement
UsernameHere1

Untitled

Feb 21st, 2024
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.16 KB | None | 0 0
  1. Imports System.IO
  2.  
  3. Public Class ForgottenPassword 'forgotten password form
  4.     Private Sub ForgottenPassword_Load(sender As Object, e As EventArgs) Handles MyBase.Load 'when form loads
  5.         Me.CenterToScreen() 'centre form to screen
  6.         Dim startupPath As String 'store the location the program is running
  7.         startupPath = Application.StartupPath
  8.         pbx_logo.ImageLocation = startupPath & "\PennardLibraryLogo.png" 'add the logo image location
  9.         pbx_back.ImageLocation = startupPath & "\Arrow.png" 'add the back image location
  10.         Me.BackColor = Color.FromArgb(163, 255, 166) 'Set the background to the standard light green
  11.     End Sub
  12.     Private Sub pbx_back_MouseHover(sender As Object, e As EventArgs) Handles pbx_back.MouseHover 'rollover image when hovered
  13.         Dim startupPath As String 'store the location the program is running
  14.         startupPath = Application.StartupPath
  15.         pbx_back.ImageLocation = startupPath & "\ArrowRollover.png" 'change image to rollover
  16.     End Sub
  17.     Private Sub pbx_back_MouseLeave(sender As Object, e As EventArgs) Handles pbx_back.MouseLeave 'go back to normal when left
  18.         Dim startupPath As String 'store the location the program is running
  19.         startupPath = Application.StartupPath
  20.         pbx_back.ImageLocation = startupPath & "\Arrow.png" 'change the image to the normal
  21.     End Sub
  22.     Private Sub pbx_back_Click(sender As Object, e As EventArgs) Handles pbx_back.Click
  23.         Dim Login As New Login 'new instance of login form
  24.         Login.Show() 'show new form
  25.         Me.Close()  'close current form
  26.     End Sub
  27.     Private Sub txt_username_MouseClick(sender As Object, e As MouseEventArgs) Handles txt_username.MouseClick
  28.         If txt_username.Text = "Username" Then 'Make text in the textbox that dissapears when clicked
  29.             txt_username.Text = "" 'clear textbox
  30.         End If
  31.     End Sub
  32.  
  33.     Private Sub btn_forgottenPassword_Click(sender As Object, e As EventArgs) Handles btn_forgottenPassword.Click
  34.         Dim encryption As New clsEncryption 'instantiate encryption class
  35.         Dim found As Boolean = False 'has the record been found
  36.         Dim record As String 'a record from the file
  37.         Dim fields() As String  'the fields in the record
  38.         Dim searchUsername As String 'the username being searched for
  39.         searchUsername = txt_username.Text 'set the value
  40.         Dim sr As New StreamReader("loginData.txt") 'a stream reader of the logindata file
  41.         While sr.Peek() >= 0 'while there are records in the file
  42.             record = encryption.decrypt(sr.ReadLine) 'decrypt the record
  43.             fields = record.Split(",") 'split the record into fields
  44.             If fields(1) = searchUsername Then 'if the username is stored in the record
  45.                 MsgBox("Your password is: " & fields(2)) 'searches for a username and the displays the password
  46.                 found = True 'record has been found
  47.             End If
  48.         End While
  49.         If found = False Then 'if record wasnt found
  50.             MsgBox("No account found with that username") 'notify user the record wasnt found
  51.         End If
  52.         sr.Close()
  53.     End Sub
  54. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement