Authentification

  • Thread starter Thread starter Bad coder dude
  • Start date Start date
B

Bad coder dude

Guest
How do I Make this so the participant is able to re-enter the password and/or the username if it is incorrect? Also how do I reset the file reader to the beginning so it doesn't crash when they try to enter there details more than the amount of lines in the file.

Here is my code:

Imports System.IO
Module Module1
Dim Password As String
Dim Passwordexists As String
Dim Username As String
Dim Usernameexists As String
Dim LoginYN As String
Dim Correct As Boolean = False
Sub Main()
While Correct = False
If IO.File.Exists("ENTER FILE HERE") Then
Console.WriteLine("Have you created a login? Enter Yes or No.")
LoginYN = Console.ReadLine
If LoginYN = "Yes" Then
Console.WriteLine("Please enter Your username")
Usernameexists = Console.ReadLine
FileOpen(1, "ENTER FILE HERE", OpenMode.Input)
While Not EOF(1)
If LineInput(1) = Usernameexists Then
Console.WriteLine("Please enter your password")
Passwordexists = Console.ReadLine
End If
If LineInput(1) = Passwordexists Then
Console.WriteLine("Password Correct press enter to continue.")
Console.ReadLine()
End If
End While
FileClose(1)
Correct = True
ElseIf LoginYN = "No" Then
FileOpen(1, "ENTER FILE HERE", OpenMode.Append)
Console.WriteLine("Please enter a Username")
Username = Console.ReadLine
PrintLine(1, Username)
Console.WriteLine("Please enter a Password")
Password = Console.ReadLine
PrintLine(1, Password)
FileClose(1)
End If
Else
Console.WriteLine("Error file not found, Please try again")
End If
End While
Console.WriteLine("Done")
Console.ReadLine()
End Sub
End Module

Continue reading...
 
Back
Top