Page 1 of 1
Listview/ Listbox Help
Posted: Mon Jul 26, 2010 12:58 pm
by upperdrag
Ok Guys Now I need help on viewing the text file in either listbox or listview.
Either i view from a file, which i need to like separate them from the ","
or i can view from the website,
one line= one item
thanks in advance.
Re: Listview/ Listbox Help
Posted: Mon Jul 26, 2010 5:10 pm
by mandai
Code: Select allDim lines As String() = File.ReadAllLines("file.txt")
For i As Integer = 0 To lines.Length - 1
ListBox1.Items.Add(lines(i))
Next
Re: Listview/ Listbox Help
Posted: Tue Jul 27, 2010 10:52 am
by upperdrag
thank you for the reply, but i was hoping to see it getting sorted out by the comma for eg
TXT FILE:
[Mary Said Hi][John Said Hi]
Listbox/Listview
[Mary Said Hi]
[John Said Hi]
Re: Listview/ Listbox Help
Posted: Tue Jul 27, 2010 7:19 pm
by mandai
Try this:
Code: Select all Dim lines As String() = File.ReadAllLines("file.txt")
For i As Integer = 0 To lines.Length - 1
Dim subitems As String() = lines(i).Split(","c)
For i2 As Integer = 0 To subitems.Length - 1
ListBox1.Items.Add(subitems(i2))
Next
Next
Where the input looks like this:
item
item2,item3,item4
item5
The output will be:
item
item2
item3
item4
item5
Re: Listview/ Listbox Help
Posted: Wed Jul 28, 2010 8:11 am
by upperdrag
THank You Mandai, +rep