Advertisement
Guest User

Untitled

a guest
May 1st, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.IO
  2.  
  3. Public Class Login
  4.  
  5.     Dim Username As String
  6.     Dim Password As String
  7.     Dim Email As String
  8.  
  9.     Dim EUsername As String 'E = Entered
  10.    Dim EPassword As String
  11.  
  12.     Dim CUsername As String 'C = Create
  13.    Dim CPassword As String
  14.     Dim Confirm As String
  15.     Dim CEmail As String
  16.     Dim Accept As Boolean
  17.  
  18.     Dim Pass As Boolean = True
  19.     Dim Found As Boolean
  20.  
  21.     Dim x As Integer
  22.     Dim y As Integer
  23.     Dim z As Integer
  24.  
  25.     Dim LEmail As Integer   'L = Length
  26.    Dim REmail As String    'R = Reversed
  27.  
  28.     Dim Temp As String
  29.  
  30.     Private Sub Login_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  31.  
  32.     End Sub
  33.  
  34.     Private Sub btnSignup_Click(sender As Object, e As EventArgs) Handles btnSignup.Click
  35.  
  36.         CUsername = txtCreateusername.Text
  37.         CPassword = txtCreatepassword.Text
  38.         Confirm = txtConfirm.Text
  39.         CEmail = txtEmail.Text
  40.  
  41.         '------------------------------------------------------------------------START-OF-VALIDATION------------------------------------------------------------------------
  42.  
  43.         '------------------------------------------------------------------------USERNAME------------------------------------------------------------------------
  44.  
  45.         If My.Computer.FileSystem.FileExists(".../USER" & CUsername & ".txt") Then
  46.             Found = True
  47.             Pass = False
  48.             If x = 0 Then
  49.                 MsgBox("Username Already Exists")
  50.                 x = 1
  51.             End If
  52.         End If
  53.  
  54.         If CUsername.Length > 30 Then
  55.             Pass = False
  56.             If x = 0 Then
  57.                 MsgBox("Username too Long (Max of 30 Characters)")
  58.                 x = 1
  59.             End If
  60.         End If
  61.  
  62.         If CUsername.Trim() = "" Then
  63.             Pass = False
  64.             If x = 0 Then
  65.                 MsgBox("Please Enter a Username")
  66.                 x = 1
  67.             End If
  68.         End If
  69.  
  70.         '------------------------------------------------------------------------PASSWORD------------------------------------------------------------------------
  71.  
  72.         If CPassword <> Confirm Then
  73.             Pass = False
  74.             If x = 0 Then
  75.                 MsgBox("Incorrect Password")
  76.                 x = 1
  77.             End If
  78.         End If
  79.  
  80.         If CPassword.Length > 30 Then
  81.             Pass = False
  82.             If x = 0 Then
  83.                 MsgBox("Password too Long (Max of 30 Characters")
  84.                 x = 1
  85.             End If
  86.         End If
  87.  
  88.         If CPassword.Trim() = "" Then
  89.             Pass = False
  90.             If x = 0 Then
  91.                 MsgBox("Please Enter a Password")
  92.                 x = 1
  93.             End If
  94.         End If
  95.  
  96.         '------------------------------------------------------------------------Email------------------------------------------------------------------------
  97.  
  98.         If CEmail.Trim() = "" Then
  99.             Pass = False
  100.             If x = 0 Then
  101.                 MsgBox("Please Enter an Email")
  102.                 x = 1
  103.             End If
  104.             REmail = "a"
  105.         End If
  106.  
  107.         If CEmail.Length >= 10 Then
  108.             LEmail = CEmail.Length
  109.             y = LEmail
  110.  
  111.             While y > (LEmail - 10)
  112.                 REmail = REmail & CEmail(y - 1)
  113.                 y = y - 1
  114.             End While
  115.  
  116.             REmail = StrReverse(REmail)
  117.         End If
  118.  
  119.         If (REmail.ToLower() <> "@gmail.com") Then
  120.             Pass = False
  121.             If x = 0 Then
  122.                 MsgBox("Please Enter a Valid Email Address")
  123.                 x = 1
  124.             End If
  125.         End If
  126.  
  127.         '------------------------------------------------------------------------ACCEPT------------------------------------------------------------------------
  128.  
  129.         If Accept = False Then
  130.             Pass = False
  131.             If x = 0 Then
  132.                 MsgBox("Please Accept Terms and Conditions")
  133.                 x = 1
  134.             End If
  135.         End If
  136.  
  137.         '------------------------------------------------------------------------END-OF-VALIDATION------------------------------------------------------------------------
  138.  
  139.         If Pass = True Then
  140.             Dim fs As FileStream = File.Create(".../USER" & CUsername & ".txt")
  141.             fs.Close()
  142.  
  143.             Using sw As StreamWriter = My.Computer.FileSystem.OpenTextFileWriter(".../USER" & CUsername & ".txt", True)
  144.                 sw.WriteLine("Username: " & CUsername & sw.NewLine() & "Password: " & CPassword & sw.NewLine() & "Email: " & CEmail)
  145.             End Using
  146.  
  147.             MsgBox("Signed Up Successfully")
  148.         End If
  149.  
  150.  
  151.         Pass = True
  152.         Found = False
  153.         x = 0
  154.         CUsername = ""
  155.         CPassword = ""
  156.         Confirm = ""
  157.         CEmail = ""
  158.         LEmail = 0
  159.         REmail = ""
  160.  
  161.         CUsername = txtCreateusername.Text = ""
  162.         txtCreatepassword.Text = ""
  163.         txtConfirm.Text = ""
  164.         txtEmail.Text = ""
  165.  
  166.     End Sub
  167.  
  168.     Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
  169.  
  170.         EUsername = txtUsername.Text
  171.         EPassword = txtPassword.Text
  172.  
  173.         If My.Computer.FileSystem.FileExists(".../USER" & EUsername & ".txt") Then
  174.             Found = True
  175.  
  176.         Else
  177.             If x = 0 Then
  178.                 MsgBox("Username Does Not Exist")
  179.                 x = 1
  180.             End If
  181.         End If
  182.  
  183.         Using sr As StreamReader = My.Computer.FileSystem.OpenTextFileReader(".../USER" & EUsername & ".txt")
  184.             Do While sr.Peek() >= 0
  185.                 If y = 0 Then
  186.                     Username = sr.ReadLine()
  187.                     y = y + 1
  188.  
  189.                 ElseIf y = 1 Then
  190.                     Password = sr.ReadLine()
  191.                     y = y + 1
  192.  
  193.                 Else
  194.                     Email = sr.ReadLine()
  195.                 End If
  196.             Loop
  197.         End Using
  198.  
  199.         z = 10
  200.  
  201.         While z < Password.Length
  202.             Temp = Temp & Password(z)
  203.             z = z + 1
  204.         End While
  205.  
  206.         Password = Temp
  207.  
  208.         If EPassword <> Password Then
  209.             Pass = False
  210.             If x = 0 Then
  211.                 MsgBox("Password Incorrect")
  212.             End If
  213.         End If
  214.  
  215.  
  216.         Pass = True
  217.         Found = False
  218.         Temp = ""
  219.         x = 0
  220.         y = 0
  221.         z = 0
  222.  
  223.         EUsername = ""
  224.         EPassword = ""
  225.         Username = ""
  226.         Password = ""
  227.         Email = ""
  228.  
  229.         txtUsername.Text = ""
  230.         txtPassword.Text = ""
  231.     End Sub
  232.  
  233.     Private Sub cbxAccept_CheckedChanged(sender As Object, e As EventArgs) Handles cbxAccept.CheckedChanged
  234.  
  235.         If Accept = False Then
  236.             Accept = True
  237.  
  238.         Else
  239.             Accept = False
  240.         End If
  241.  
  242.     End Sub
  243.  
  244.     Private Sub Button1_Click(sender As Object, e As EventArgs)
  245.  
  246.     End Sub
  247. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement