0

I have 10 NumericUpDowns. I want them when to reach the limit of 14 and then the last NumericUpDown the user clicked only can be decreased or stay the same after the msgbox display, I set the limit to each is 4

Private Sub Chkval()
        Dim storeval(11) As Integer
        storeval(0) = NumericUpDown1.Value
        storeval(1) = NumericUpDown2.Value
        storeval(2) = NumericUpDown3.Value
        storeval(3) = NumericUpDown4.Value
        storeval(4) = NumericUpDown5.Value
        storeval(5) = NumericUpDown6.Value
        storeval(6) = NumericUpDown13.Value
        storeval(7) = NumericUpDown14.Value
        storeval(8) = NumericUpDown18.Value
        storeval(9) = NumericUpDown19.Value
        If storeval.Sum > 14 Then
            MsgBox("ok")
        End If
    End Sub
3
  • 2
    Think about what you're asking for. When the Value changes in one control, you want to set the maximum Value that can be selected in other controls. Is there an event that's raised when the Value property changes? Is there a property that determines the maximum for the Value property? Commented May 26, 2022 at 1:16
  • Please include the detailed code. There's a lot of missing details in your question. Commented May 26, 2022 at 2:27
  • sorry my question may be a little confusing and my code as well, so I have 10 NUM and I want to check if the value for two of them add up together reaches 14, then the last one NUM the user clicks after the MSGbox displayed dont increase a number i want something can stop the NUM kepping going up after Msgbox displayed. Commented Jun 2, 2022 at 0:34

1 Answer 1

0

Just hook all the 10 numericupdowns' ValueChanged event to a single event handler and in that handler check if the sum of all the values has exceeded 14. If so, then decrease the sender numericupdown's value so that the sum = 14.

Sign up to request clarification or add additional context in comments.

1 Comment

I tried that, but what I want to achieve is that when the value is greater than 14 , it decreases the last numericupdown vlaue

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.