You can also use a data set to hold all the information from the file. I just read a section in my book that has the code. Here it is.
VB Code:
Dim ds As New DataSet() Dim table As New DataTable("MyTable") ds.Tables.Add("MyTable") Dim counter As Integer Dim col As DataColumn ' You only have three columns in your file, at least that is what I ' read in your previous post. If you had more columns of text to ' be seperated, you would change this number accordingly. For counter = 0 to 2 col = New DataColumn("Column " & counter.ToString()) ds.Tables("MyTable").Columns.Add(col) Next Dim reader As New StreamReader("YourFilePathAndName") Dim mystring As String While reader.Peek <> -1 mystring = reader.ReadLine ds.Tables("MyTable").Rows.Add(mystring.Split(","c)) 'Instead of just splitting them, you might want to take off 'all leading and trailing spaces. End While




Reply With Quote