Advertisement
Guest User

Untitled

a guest
Jan 12th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. Using rdr As New FileIO.TextFieldParser("f:ComputingSpelling Beestdnt&staffdtls.csv")
  2. rdr.TextFieldType = FieldType.Delimited
  3. rdr.Delimiters = New String() {","c}
  4. item = rdr.ReadFields()
  5. End Using
  6. Console.Write("Username: ")
  7. enteredusername = Console.ReadLine
  8. Console.Write("Password: ")
  9. Dim info As ConsoleKeyInfo
  10. Do
  11. info = Console.ReadKey(True)
  12. If info.Key = ConsoleKey.Enter Then
  13. Exit Do
  14. End If
  15. If info.Key = ConsoleKey.Backspace AndAlso enteredpassword.Length > 0 Then
  16. enteredpassword = enteredpassword.Substring(0, enteredpassword.Length - 1)
  17. Console.Write(vbBack & " ")
  18. Console.CursorLeft -= 1
  19. Else
  20. enteredpassword &= info.KeyChar
  21. Console.Write("*"c)
  22. End If
  23. Loop
  24. Dim foundItem() As String = Nothing
  25. For Each line As String In File.ReadAllLines("f:ComputingSpelling Beestdnt&staffdtls.csv")
  26. Dim item() As String = line.Split(","c)
  27. If (enteredusername = item(0)) And (enteredpassword = item(1)) Then
  28. foundItem = item
  29. Exit For
  30. End If
  31. Next
  32.  
  33. Public Class MainClass
  34.  
  35. Public Shared enteredusername As String
  36. Public Shared enteredpassword As String
  37.  
  38. Private Sub SomeSub()
  39. ' Some Code ...
  40.  
  41. ' You can access it here:
  42. enteredusername = "something"
  43. enteredpassword = "something else"
  44.  
  45. ' ... More Code ...
  46. End Sub
  47. End Class
  48.  
  49. Public Class AnotherClass
  50. 'Also, please note, that this class can also be in another file.
  51.  
  52. Private Sub AnotherSub()
  53. ' Some Code ...
  54.  
  55. ' You can also access the variable here, but you need to specify what class it is from, like so:
  56. Console.WriteLine(MainClass.enteredusername)
  57. Console.WriteLine(MainClass.enteredpassword)
  58.  
  59. ' ... More Code ...
  60. End Sub
  61. End Class
  62.  
  63. Dim AC As New AnotherClass
  64. AC.AnotherSub()
  65.  
  66. AnotherClass.AnotherSub()
  67.  
  68. Class TheClassName
  69. Dim enteredusername As String
  70. Dim enteredpassword As String
  71. ...
  72. End Class
  73.  
  74. Module TheModuleName
  75. Dim enteredusername As String
  76. Dim enteredpassword As String
  77. ...
  78. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement