Split on tab character

  • Thread starter Thread starter Robert Strickland
  • Start date Start date
R

Robert Strickland

I need to split on the tab character found in a string. What is used for the
character?
 
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
 
Dim str As String = "This contains a" & vbTab & "Tab"

MessageBox.Show(str.Split(ControlChars.Tab)(0))
MessageBox.Show(str.Split(ControlChars.Tab)(1))

hope that helps..
Imran.
 
That worked nicely.

Thanks

scorpion53061 said:
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
 
Robert Strickland said:
I need to split on the tab character found in a string.
What is used for the character?

'ControlChars.Tab' or 'vbTab'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top