Hi
I have a set of numeric up-downs (A, B, and C) whose values should add up to less than or equal to the value of another numeric up-down (Total).
The Total value is the number of units available to be allocated between one or more Slots. Any combination of values in A, B, and C is valid, as long as A+B+C adds up to <= T. T itself can be any value.
My idea so far was this, but I can't get it to work at all.
Any advice would be appreciated.
I have a set of numeric up-downs (A, B, and C) whose values should add up to less than or equal to the value of another numeric up-down (Total).
The Total value is the number of units available to be allocated between one or more Slots. Any combination of values in A, B, and C is valid, as long as A+B+C adds up to <= T. T itself can be any value.
My idea so far was this, but I can't get it to work at all.
VB.NET:
Sub SetTotal(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nud_Total.ValueChanged, nud_SlotA.ValueChanged, nud_SlotB.ValueChanged, nud_SlotC.ValueChanged
Dim toSpend As Integer = nud_Total.Value - (nud_SlotA.Value + nud_SlotB.Value + nud_SlotC.Value)
If sender.Value <= toSpend Then
nud_SlotA.Maximum = toSpend
nud_SlotB.Maximum = toSpend
nud_SlotC.Maximum = toSpend
End If
End Sub
Any advice would be appreciated.
Last edited: