digimortal
Programmer
Hi,
I got Listboxs like this:
First Second
1 3
1 4
1 3
2 5
3 4
3 2
4 1
5 7
5 5
What I need is to remove the duplicate items from the first one and sum all the corresponding values in the second one, so the example become:
1 10
2 5
3 6
4 1
5 12
This is the code I wrote but it does not work;
I got Listboxs like this:
First Second
1 3
1 4
1 3
2 5
3 4
3 2
4 1
5 7
5 5
What I need is to remove the duplicate items from the first one and sum all the corresponding values in the second one, so the example become:
1 10
2 5
3 6
4 1
5 12
This is the code I wrote but it does not work;
Code:
While RowCounter < ColorListB.Items.Count - 2
RCG = RowCounter+1
While ColorListB.Items.Item(RowCounter).Text = ColorListB.Items.Item(RCG).Text
QuantityListB.Items.Item(RowCounter).Text = CDbl(QuantityListB.Items.Item(RowCounter).Text) + CDbl(QuantityListB.Items.Item(RCG).Text)
ColorListB.Items.RemoveAt(RCG)
QuantityListB.Items.RemoveAt(RCG)
RCG += 1
End While
RowCounter += 1
End While