# VB Listbox help



## [I.R.A]_FBi (Mar 9, 2009)

Lets say i have a listbox that is supposed to be separated by newlines how would i read the stuff in and out?


----------



## FordGT90Concept (Mar 9, 2009)

ListBox is index-based.  You can access an item via "MyListBox.Items(index)."


A textbox can support the new line character if Multiline = true.  If you want an empty line in a ListBox, you'll just have to add an zero-length item like so: MyListBox.Items.Add("")


----------



## [I.R.A]_FBi (Mar 9, 2009)

how do you get the size of index?

also thanks!


----------



## Deleted member 3 (Mar 9, 2009)

listbox.selecteditem, it's a collection so you'll have to loop through it even if you can select only one thus expect only a single result.


----------



## FordGT90Concept (Mar 9, 2009)

[I.R.A]_FBi said:


> how do you get the size of index?
> 
> also thanks!


MyListBox.Items.Count

You can use a For Each or For loop to go through the collection.


```
For Each item As String In MyListBox.Items
  ...
Next
```


```
For index As Integer = 0 To MyListBox.Items.Count - 1
  ...
Next
```


----------

