Reading From Text file VB .NET (Text file to Listbox)  

Posted by Kunal Pradhan

For reading id and password while making orkut related software or any other site related software use below code
FOR ID
If My.Computer.FileSystem.FileExists("id.txt") Then
Dim stream_reader As New IO.StreamReader("id.txt")
ListBox1.Items.AddRange(Split(stream_reader.ReadToEnd, _
vbCrLf))
ListBox1.SelectedIndex = 0
stream_reader.Close()
Else
My.Computer.FileSystem.OpenTextFileWriter("id.txt", True)
MsgBox("The Software has created files required for this Software, please fill required information in them, Then run this program, For now the program is Closing!", MsgBoxStyle.Critical, "Error!")
Me.Close()
End If

FOR PASSWORD
If My.Computer.FileSystem.FileExists("passwd.txt") Then
Dim stream_reader As New IO.StreamReader("passwd.txt")
ListBox2.Items.AddRange(Split(stream_reader.ReadToEnd, _
vbCrLf))
ListBox2.SelectedIndex = 0
stream_reader.Close()
Else
My.Computer.FileSystem.OpenTextFileWriter("passwd.txt", True)
MsgBox("The Software has created files required for this Software, please fill required information in them, Then run this program, For now the program is Closing!", MsgBoxStyle.Critical, "Error!")
Me.Close()
End If

This entry was posted on Wednesday, June 18, 2008 and is filed under , , , , , , . You can leave a response and follow any responses to this entry through the Subscribe to: Post Comments (Atom) .

0 comments