Tab Delimited File

  • Thread starter Thread starter Ot
  • Start date Start date
O

Ot

I have a Tab delimited file: Field1<tab>Field2<tab>...<Field20><crlf>

There must be an easy way to break this apart, but I haven't found it yet.
Can anyone help?

Regards,
Ot
 
* "Ot said:
I have a Tab delimited file: Field1<tab>Field2<tab>...<Field20><crlf>

There must be an easy way to break this apart, but I haven't found it yet.

You can use 'Split' to split the lines.
 
Sure. String.Split() is going to be your friend here. It will split the
string into an array of strings - for your example, splitting on <tab> would
give you an array of strings { "Field1", "Field2", "...","Field20"}

Here's an example that will read in each line, then print out each field on
it's own line:

------------------------------------
Imports System.IO

Module Module1
Sub Main()
Dim reader As New StreamReader("c:\filename.txt")

Dim oneLine As String = reader.ReadLine()
While Not oneLine Is Nothing
Dim vals() As String = oneLine.Split(vbTab)

'Do something interesting with the array of strings
Dim s As String
For Each s In vals
Console.WriteLine(s)
Next

oneLine = reader.ReadLine()
End While
End Sub
End Module
 
Back
Top