Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Using rdr As New FileIO.TextFieldParser("f:ComputingSpelling Beestdnt&staffdtls.csv")
- rdr.TextFieldType = FieldType.Delimited
- rdr.Delimiters = New String() {","c}
- item = rdr.ReadFields()
- End Using
- Console.Write("Username: ")
- enteredusername = Console.ReadLine
- Console.Write("Password: ")
- Dim info As ConsoleKeyInfo
- Do
- info = Console.ReadKey(True)
- If info.Key = ConsoleKey.Enter Then
- Exit Do
- End If
- If info.Key = ConsoleKey.Backspace AndAlso enteredpassword.Length > 0 Then
- enteredpassword = enteredpassword.Substring(0, enteredpassword.Length - 1)
- Console.Write(vbBack & " ")
- Console.CursorLeft -= 1
- Else
- enteredpassword &= info.KeyChar
- Console.Write("*"c)
- End If
- Loop
- Dim foundItem() As String = Nothing
- For Each line As String In File.ReadAllLines("f:ComputingSpelling Beestdnt&staffdtls.csv")
- Dim item() As String = line.Split(","c)
- If (enteredusername = item(0)) And (enteredpassword = item(1)) Then
- foundItem = item
- Exit For
- End If
- Next
- Public Class MainClass
- Public Shared enteredusername As String
- Public Shared enteredpassword As String
- Private Sub SomeSub()
- ' Some Code ...
- ' You can access it here:
- enteredusername = "something"
- enteredpassword = "something else"
- ' ... More Code ...
- End Sub
- End Class
- Public Class AnotherClass
- 'Also, please note, that this class can also be in another file.
- Private Sub AnotherSub()
- ' Some Code ...
- ' You can also access the variable here, but you need to specify what class it is from, like so:
- Console.WriteLine(MainClass.enteredusername)
- Console.WriteLine(MainClass.enteredpassword)
- ' ... More Code ...
- End Sub
- End Class
- Dim AC As New AnotherClass
- AC.AnotherSub()
- AnotherClass.AnotherSub()
- Class TheClassName
- Dim enteredusername As String
- Dim enteredpassword As String
- ...
- End Class
- Module TheModuleName
- Dim enteredusername As String
- Dim enteredpassword As String
- ...
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement