Reputation: 23
HI I need a little help.
Part of my Problem:
- First, Read a text file.
- Add the items from text file into TextBox and ListBox.
Sample Data in my text file is like this:
A;Cat;Dog;Rat;Bird
Where, ";" is the Delimiter and data is just one line only.
"A" has to load in TextBox and "Cat,.....,Bird" has to load in ListBox, one line per animal.
I've already read the text file and load "A" into text box.
But couldn't figure out how to load rest of the data into list box.
Any help would be great.
Upvotes: 0
Views: 2739
Reputation: 4361
This is really simple and you should have a look at the MSDN page to learn more on ListBox and other related stuff.
Dim str As String = "A;Cat;Dog;Rat;Bird" 'should have read from your text file
Dim arr As String() = str.Split(New Char() {";"})
Dim i As Integer
For i = 1 To arr.Length - 1
ListBox1.Items.Add(arr(i))
Next i
Upvotes: 2
Reputation: 1224
string[] strArrr = "A;Cat;Dog;Rat;Bird".Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 1;i< strArrr.Length - 1; i++)
{
listbox.items.add(strarrr[i]);
}
Upvotes: 1