Advertisement
Guest User

Untitled

a guest
Jan 12th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. Public Sub LoadAccount()
  2. currentfilereader = New StreamReader(filename)
  3. Dim Seperator As Char = " "c
  4. For count As Integer = 0 To NumUsers - 1
  5. textstring = currentfilereader.ReadLine
  6. Dim words() As String = currentfilereader.ReadLine.Split(Seperator)
  7. Username = words(0)
  8. Password = words(1)
  9. If words(2) = "1" Then
  10. AccessGranted = True
  11. Else
  12. AccessGranted = False
  13. End If
  14. Users(count, 0) = Username
  15. Users(count, 1) = Password
  16. Users(count, 2) = AccessGranted
  17. Next
  18. currentfilereader.Close()
  19. End Sub
  20.  
  21. Public Sub Login()
  22. Dim InvalidUsername, InvalidPassword As Boolean
  23. InvalidUsername = True
  24. InvalidPassword = True
  25. LoginName = Form1.tbun.Text
  26. LoginPassword = Form1.tbpw.Text
  27. For count As Integer = 0 To NumUsers - 1
  28. If LoginName = Users(count, 0) Then
  29. InvalidUsername = False
  30. If LoginPassword = Users(count, 1) Then
  31. InvalidPassword = False
  32. CurrentUsername = LoginName
  33. CurrentPassword = LoginPassword
  34. CurrentAccessGranted = Users(count, 2)
  35. loggedin = True
  36. Else
  37. MsgBox("Invalid Password")
  38. End If
  39. Else
  40. MsgBox("Invalid Username")
  41. End If
  42. Next
  43. End Sub
  44.  
  45. Public Sub NumberOfUsers()
  46. currentfilereader = New StreamReader(filename)
  47. NumUsers = File.ReadAllLines("Accounts.txt").Length
  48. MsgBox("There are " & NumUsers & " users")
  49. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement