searching listbox with text from label

Brian

New member
Joined
Nov 28, 2021
Messages
2
Programming Experience
Beginner
Good day
im very new at programming c#
your help will be really appreciated
im trying to check and subtract from my label the number thats in a listbox (label starts with 6000)
first item found must subtract that from the value in the label and remove number from listbox
then proceed to next item in the listbox and do the same
until the value in the label is less than the number in the listbox
then it must move the balance in label to another listbox
then replace label with 6000 for next loop

i hope i makes sense

Brian Chetty
 
The first problem you have is that you are manipulating data held within the UI controls. That is the 1980's way of writing code. The modern way of writing code is that the UI simply reflects the state of your data. You do the manipulations on the data itself, and the UI will show those changes.
 
The first problem you have is that you are manipulating data held within the UI controls. That is the 1980's way of writing code. The modern way of writing code is that the UI simply reflects the state of your data. You do the manipulations on the data itself, and the UI will show those changes.
Thanks Skydiver

do you have a project or sample code that i can learn from
 
I'm feeling generous. Here's some pseudo-code:
C#:
let subtrahends = { array of values to try to subtract from the minuend sorted in descending order }
let differences = { empty array }

do
{
    let minuend = 6000

    for(int i = 0; i < subtrahends.Length; i++)
    {
        while (minuend > subtrahend[i])
            minuend = minuend - subtrahend[i]
    }

    differences.Add(minuend)
} while (true)
 
Back
Top Bottom