Hi,
I have 3 columns in a listbox (Code, Item, Qty).
I was trying to calculate the quantity based from code column.
dim dictContent as new Dictionary
const col_code =0
const col_item = 1
const col_qty = 2
for i as integer = 0 to ListBox1.ListCount-1
dim key as String = ListBox1.Cell(i,col_code)+";"+ListBox1.Cell(i,col_item)
if dictContent.HasKey(key) Then
dictContent.Value(key) = dictContent.Value(key).IntegerValue + Val(ListBox1.Cell(i,col_qty))
else
dictContent.Value(key) = Val(ListBox1.Cell(i,col_qty))
end
next
ListBox1.DeleteAllRows
for i as integer = 0 to dictContent.Count-1
dim key as String = dictContent.Key(i)
dim value as String = Str(dictContent.Value(key).IntegerValue)
ListBox1.AddRow(key.NthField(";",0),key.NthField(";",1),key.NthField(";",2))
next
When I do execute this code, the result was not that I expected. The Listbox Column 0 was empty, code column was moved into column 1 .
I was expecting the listbox cloumn 0 is the code, column 1 is item name and column 2 is the qty calculation.
any helps.
thanks
arief