ii i am tryin to split up a text file using vb.net.The text file contains username and password in the format usernameassword.What i am tryin to do is to split up the text file based on the delimiter(":") and store the username and pass in two different strings. here is a small snippet of code i am using Dim FILE_NAME As String = "uname.txt" Dim TextLine As String If System.IO.File.Exists(FILE_NAME) = True Then Dim objReader As New System.IO.StreamReader(FILE_NAME) Do While objReader.Peek() <> -1 TextLine = TextLine & objReader.ReadLine() & vbNewLine Loop Textbox1.Text = TextLine Else MsgBox("File Does Not Exist") End If Also i want to place each username and pass one by one in the string so that i can use them with my code.. Any Help will be highly appreciated..
For each line you have, you can use following function to read username and password: Private Sub GrabUser(ByVal line As String, ByRef username As String, ByRef password As String) Dim fields As String() = line.Split(New [Char]() {":"c}) username = fields(0) If UBound(fields) > 1 Then password = fields(1) End If End Sub Code (markup):