Possible Duplicate:
Parse Delimited CSV in .NET
Hi,
How can I convert a csv string into a list in vb.net?
Possible Duplicate:
Parse Delimited CSV in .NET
Hi,
How can I convert a csv string into a list in vb.net?
You want something like this...
Dim MyString as String = "one,two,three,four,five"
Dim MyArray() as String = Mystring.Split(",")
Dim MyList as List(Of String) = MyArray.ToList()
Hope this helps!
"one,two",two,three
using Linq:
Dim parts As String = "1,2,3,4"
Dim itemsList As List(Of String)
itemsList = (From s In parts.Split(",")
Select s).ToList()
Gives you a list with 4 items
Take a look at the split function.
Dim a As String
a = "data1,2,3,4,5"
Dim b() As String
b = a.Split(",")
Dim c As List(Of String)
c = b.ToList()
c will be a list of strings
"one,two",two,three
Dim a As String a = "data1,2,3,4,5" Dim c As List(Of String) c = a.Split(",").ToList()
string.split
will work. However, this is not an answer because it's about as "correct" as using a regex to parse HTML. I am pretty sure the VisualBasic namespace contains support for CSV file/stream parsing, so that would be a place to look.