Advertisement
kshadow22

Advanced Log In With IO Visual Basic

Jun 30th, 2015
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. LOG IN FORM ================================================
  2. Public Class Form1
  3.     Dim Username001 As String = Nothing
  4.     Dim Password001 As String = Nothing
  5.     Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
  6.  
  7.     End Sub
  8.     Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
  9.  
  10.     End Sub
  11.  
  12.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  13.         If System.IO.File.Exists(Application.StartupPath & "\" & TextBox1.Text) Then
  14.             Dim objreader As New System.IO.StreamReader(Application.StartupPath & "\" & TextBox1.Text)
  15.             Username001 = objreader.ReadLine
  16.             Password001 = objreader.ReadLine
  17.             objreader.Close()
  18.             If TextBox1.Text = Username001 Then
  19.                 If TextBox2.Text = Password001 Then
  20.                     Form2.Show()
  21.                     GoTo EndOfScript
  22.                 End If
  23.             End If
  24.         End If
  25.         MessageBox.Show("Username or Password is incorrect!")
  26. EndOfScript:
  27.     End Sub
  28.  
  29.    
  30.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  31.         Register.Show()
  32.         Me.Hide()
  33.     End Sub
  34.  
  35.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  36.  
  37.     End Sub
  38. End Class
  39.  
  40. REGISTER FORM ============================================
  41. Public Class Register
  42.  
  43.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  44.         If System.IO.File.Exists(Application.StartupPath & "\" & TextBox1.Text) Then 'Checks To See If The File Path Exists
  45.            System.IO.File.Delete(Application.StartupPath & "\" & TextBox1.Text) 'Deletes The File Path IF It Exists
  46.            Dim objwriter As New System.IO.StreamWriter(Application.StartupPath & "\" & TextBox1.Text) 'Writes/ Creates A File Patj and File
  47.            objwriter.WriteLine(TextBox1.Text) 'Username
  48.            objwriter.WriteLine(TextBox2.Text) 'Password
  49.            objwriter.Close() 'Closes Our Object Writer
  50.        Else
  51.             Dim objwriter As New System.IO.StreamWriter(Application.StartupPath & "\" & TextBox1.Text)
  52.             objwriter.WriteLine(TextBox1.Text) 'Username
  53.            objwriter.WriteLine(TextBox2.Text) 'Password
  54.            objwriter.Close()
  55.         End If
  56.         Form1.Show()
  57.         Me.Close()
  58.     End Sub
  59.  
  60.     Private Sub Register_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  61.  
  62.     End Sub
  63. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement