# Vb 2005 looping listbox

**URL:** <https://forum.kirupa.com/t/vb-2005-looping-listbox/214302>\
**Category:** Uncategorized\
**Created:** [January 27, 2007, 3:59am UTC](https://forum.kirupa.com/t/vb-2005-looping-listbox/214302 "2007-01-27T03:59:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kitaeshi](https://avatars.discourse-cdn.com/v4/letter/k/9f8e36/32.png) [@kitaeshi](https://forum.kirupa.com/u/kitaeshi)\
**Post date:** [January 27, 2007, 3:59am UTC](https://forum.kirupa.com/t/vb-2005-looping-listbox/214302/1 "2007-01-27T03:59:53Z")

</div>

Hi all i need help on listbox.

The itemlistbox fill with 3 item and the price of the three item will be on the array

when select the itemlistbox item and click add, it will update on an orderlistbox and it will also retrieve the price from the array and add to total amount.

since u can add, there is also a delete item. I hav done the code on delete the item on the orderlistbox but the problem is to minu the deleted item price at totalprice

i try to use a if statement n inside i create a for loop to loop inside itemlistbox to get the index of the array to retrieve the price, but the looping dun seem to work on listbox -\_-

is there any way to solve it? or is it possible to assign a value on the item inside the listbox?

thanks for reading.

Dim intCount As Integer = 0  
Dim listCount As Integer = itemListbox.Items.Count - 1  
If (purchaseListbox.SelectedIndex) Then  
For intCount = 0 To listCount  
If purchaseListbox.SelectedItem = itemListbox.Items(intCount) Then  
totalAmount -= itemPrice(intCount)  
End If

```
        Next
    End If
```
