I'm having some trouble. I have a file who's contents are :
"Bob Jones", 1, "A-", "Introduction to CS"
"Sarah Johnson", 2, "B+", "Data Structures"
"Sam Smith", 3, "A", "Visual Basic"
I'm not sure how to read this file and have it display as :
Bob Jones 1 A- Introduction to CS
Sarah Johnson 2 B+ Data Structures
Sam Smith 3 A Visual Basic
As you can see, I'm really floundering around with the below code.
"Bob Jones", 1, "A-", "Introduction to CS"
"Sarah Johnson", 2, "B+", "Data Structures"
"Sam Smith", 3, "A", "Visual Basic"
I'm not sure how to read this file and have it display as :
Bob Jones 1 A- Introduction to CS
Sarah Johnson 2 B+ Data Structures
Sam Smith 3 A Visual Basic
As you can see, I'm really floundering around with the below code.
VB.NET:
Imports System.IO
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fileName As String
fileName = ("D:\Data.txt")
If File.Exists(fileName) Then
Try
Dim stream As New StreamReader(fileName)
Dim sLine As String = stream.ReadLine
While Not sLine Is Nothing
stream.ReadLine.Split(","c)
txtOutput.Text = stream.ReadLine
sLine = stream.ReadLine()
End While
Catch ex As System.IO.IOException
MessageBox.Show("Error reading from file", "File Error", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End Sub