awmantonio 0 Newbie Poster

HI guys! I have a listview that shows all the installment amount of an item. I have a button that calculates each amount when the amount paid is entered in a textbox. With this, how can I code it deduct to the next amount if the paid amount is greater than what should be paid? Or if bigger than the next term, deduct the excess to the amount next to it until all of the amount is fully paid?

ctrlno amount
1 45
2 45
3 45
4 45

If amount entered in the txtPayAmt is 100 while the selected row is on the 1st ctrlno:

ctrlno amount
1 0
2 0
3 35
4 45

Or if the buyer decided to pay all on the first term (45 x 5 = 225 so amount entered in txtPayAmt is 225)

ctrlno amount
1 0
2 0
3 0
4 0

I'm thinking of using loops but I'm wondering what's the most appropriate and also what's the structure of the coding.

Any help please? Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.