# Calculating number listed in listbox

Hi,

I have 10 rows in a listbox,

```10 10 20 10 20 20 30 10 10 10```

my question, is it possible to count the total of each number without define the criteria, so just calculate automatically which listed in listbox.
what i am expected the result should be,

```10 -->6 times 20 -->3 times 30 -->1 time```

thanks
regards,
arief

Use a dictionary. Just written down:

```dim d as new dictionary for currentRow as integer = 0 to listbox.rowcount - 1 dim theNumber as integer = val(listbox.cell(currentrow, 0) if d.haskey(thenumber) then d.value(thenumber) = val(d.value(thenumber)) + 1 else d.value(thenumber) = 1 next```

similar

[code]Dim d As New dictionary

For Each row As ListboxRow In Listbox1.Rows
Dim key As String = row.ColumnValueAt(0)
d.value(key) = 0
End If
d.value(key) = d.value(key) + 1
Next

For Each key As String In d.Keys
System.DebugLog(key+ “=” + d.value(key))
Next[/code]

also similar

```dim d as new dictionary for currentRow as integer = 0 to listbox.rowcount - 1 dim theNumber as integer = val(listbox.cell(currentrow, 0)) d.value(thenumber) = d.lookup(thenumber, 0) + 1 next```

Hi,
thanks for the helps.

I have done it in a listbox, I will give a try. Its really hard to get the result in a textarea like,

```10 -->6 times 20 -->3 times 30 -->1 time```

thanks
Arief

u just add this text together in a string with line breaks and give it the .Text or .Value Property.