Separating a text file into different variables

Adrammelech

Member
Joined
Mar 9, 2007
Messages
11
Programming Experience
Beginner
I've been trying to get this to work but I never got it down right but now I'm working on a program that I need to get it to work or else the program is nothing. I have a login form that saves into a file like-
Name
Password
HP

Name
Password
HP
...

The problem is I want it where when I type in a username, it searches for a corresponding name, and checks the line under it to see if the password corresponds with the name, and if it does, it saves the name as characterName, the password as characterPassword, and so on. The problem I've had before is getting it to check the document, and I don't have a clue what to do.
 
To read a file, try the following :


VB.NET:
Imports System.IO
...
Using sr As StreamReader = New StreamReader(textfile)
//insert code here
End Using
sr.close()

Then use sr.readline to read a line into a variable. This also will move the position to the next line in the file, making it easy to just call sr.readline again to check the password.
 
Back
Top