Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.IO
- Public Class Login
- Dim Username As String
- Dim Password As String
- Dim Email As String
- Dim EUsername As String 'E = Entered
- Dim EPassword As String
- Dim CUsername As String 'C = Create
- Dim CPassword As String
- Dim Confirm As String
- Dim CEmail As String
- Dim Accept As Boolean
- Dim Pass As Boolean = True
- Dim Found As Boolean
- Dim x As Integer
- Dim y As Integer
- Dim z As Integer
- Dim LEmail As Integer 'L = Length
- Dim REmail As String 'R = Reversed
- Dim Temp As String
- Private Sub Login_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- End Sub
- Private Sub btnSignup_Click(sender As Object, e As EventArgs) Handles btnSignup.Click
- CUsername = txtCreateusername.Text
- CPassword = txtCreatepassword.Text
- Confirm = txtConfirm.Text
- CEmail = txtEmail.Text
- '------------------------------------------------------------------------START-OF-VALIDATION------------------------------------------------------------------------
- '------------------------------------------------------------------------USERNAME------------------------------------------------------------------------
- If My.Computer.FileSystem.FileExists(".../USER" & CUsername & ".txt") Then
- Found = True
- Pass = False
- If x = 0 Then
- MsgBox("Username Already Exists")
- x = 1
- End If
- End If
- If CUsername.Length > 30 Then
- Pass = False
- If x = 0 Then
- MsgBox("Username too Long (Max of 30 Characters)")
- x = 1
- End If
- End If
- If CUsername.Trim() = "" Then
- Pass = False
- If x = 0 Then
- MsgBox("Please Enter a Username")
- x = 1
- End If
- End If
- '------------------------------------------------------------------------PASSWORD------------------------------------------------------------------------
- If CPassword <> Confirm Then
- Pass = False
- If x = 0 Then
- MsgBox("Incorrect Password")
- x = 1
- End If
- End If
- If CPassword.Length > 30 Then
- Pass = False
- If x = 0 Then
- MsgBox("Password too Long (Max of 30 Characters")
- x = 1
- End If
- End If
- If CPassword.Trim() = "" Then
- Pass = False
- If x = 0 Then
- MsgBox("Please Enter a Password")
- x = 1
- End If
- End If
- '------------------------------------------------------------------------Email------------------------------------------------------------------------
- If CEmail.Trim() = "" Then
- Pass = False
- If x = 0 Then
- MsgBox("Please Enter an Email")
- x = 1
- End If
- REmail = "a"
- End If
- If CEmail.Length >= 10 Then
- LEmail = CEmail.Length
- y = LEmail
- While y > (LEmail - 10)
- REmail = REmail & CEmail(y - 1)
- y = y - 1
- End While
- REmail = StrReverse(REmail)
- End If
- If (REmail.ToLower() <> "@gmail.com") Then
- Pass = False
- If x = 0 Then
- MsgBox("Please Enter a Valid Email Address")
- x = 1
- End If
- End If
- '------------------------------------------------------------------------ACCEPT------------------------------------------------------------------------
- If Accept = False Then
- Pass = False
- If x = 0 Then
- MsgBox("Please Accept Terms and Conditions")
- x = 1
- End If
- End If
- '------------------------------------------------------------------------END-OF-VALIDATION------------------------------------------------------------------------
- If Pass = True Then
- Dim fs As FileStream = File.Create(".../USER" & CUsername & ".txt")
- fs.Close()
- Using sw As StreamWriter = My.Computer.FileSystem.OpenTextFileWriter(".../USER" & CUsername & ".txt", True)
- sw.WriteLine("Username: " & CUsername & sw.NewLine() & "Password: " & CPassword & sw.NewLine() & "Email: " & CEmail)
- End Using
- MsgBox("Signed Up Successfully")
- End If
- Pass = True
- Found = False
- x = 0
- CUsername = ""
- CPassword = ""
- Confirm = ""
- CEmail = ""
- LEmail = 0
- REmail = ""
- CUsername = txtCreateusername.Text = ""
- txtCreatepassword.Text = ""
- txtConfirm.Text = ""
- txtEmail.Text = ""
- End Sub
- Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
- EUsername = txtUsername.Text
- EPassword = txtPassword.Text
- If My.Computer.FileSystem.FileExists(".../USER" & EUsername & ".txt") Then
- Found = True
- Else
- If x = 0 Then
- MsgBox("Username Does Not Exist")
- x = 1
- End If
- End If
- Using sr As StreamReader = My.Computer.FileSystem.OpenTextFileReader(".../USER" & EUsername & ".txt")
- Do While sr.Peek() >= 0
- If y = 0 Then
- Username = sr.ReadLine()
- y = y + 1
- ElseIf y = 1 Then
- Password = sr.ReadLine()
- y = y + 1
- Else
- Email = sr.ReadLine()
- End If
- Loop
- End Using
- z = 10
- While z < Password.Length
- Temp = Temp & Password(z)
- z = z + 1
- End While
- Password = Temp
- If EPassword <> Password Then
- Pass = False
- If x = 0 Then
- MsgBox("Password Incorrect")
- End If
- End If
- Pass = True
- Found = False
- Temp = ""
- x = 0
- y = 0
- z = 0
- EUsername = ""
- EPassword = ""
- Username = ""
- Password = ""
- Email = ""
- txtUsername.Text = ""
- txtPassword.Text = ""
- End Sub
- Private Sub cbxAccept_CheckedChanged(sender As Object, e As EventArgs) Handles cbxAccept.CheckedChanged
- If Accept = False Then
- Accept = True
- Else
- Accept = False
- End If
- End Sub
- Private Sub Button1_Click(sender As Object, e As EventArgs)
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement