Need help figuring out a code for the numericUpDown min and maximum

Ok so I got the main part of the assignment done and my teacher added a part to the assiment seperate from the book. Ok I have to add a starting rate NumericUpDown control and a Ending Rate NumericUpDown control. So I figured out how to get the Starting Rate minimum to be set at 2 and the maximum to be set at 20 because you can do that in the properties box on the right side but now for the EndingRate NumericUpDown I have to make the minimum to always be 2 more than the StartingRate current value and the EndingRate Maximum to always be 10 more than the Starting Rate current value and I cant figure out how to write a code for that and its starting to become a bit frustrating. Any help would be greatly appriciated.
Who is Participating?

Improve company productivity with a Business Account.Sign Up

Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:

"my teacher says that it has to automatically update the EndingRateNumericUpDown every time I adjust the StartingRateNumericUpDown"

Now WHERE, read that as "which EVENT", can we place that code?
Mike TomlinsonMiddle School Assistant TeacherCommented:
Handle the ValueChanged() event of the starting rate NumericUpDown and change the ending rate min/max values accordingly:
Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
        ' ... do something in here to change the min/max values of NumericUpDown2 ...
    End Sub

Open in new window

goldfingerpunkAuthor Commented:
right I got that far but the book i have doesnt even explain what to do and Im clueless on what to put in there to make it work here is what i put in sofar and it doesnt work....
For EndingRateNumericUpDown1.Minimum = StartingRateNumericUpDown1.Value To EndingRateNumericUpDown1.Value Step 2
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Mike TomlinsonMiddle School Assistant TeacherCommented:
NO for loops are needed here...   ;)

To get the CURRENT number in the first NumericUpDown you would use the .Value() property:

Now add 2 to that and set the Minimum() property:

...and add 10 to it and set the Maximum() property:

YOU CAN DO IT!  Go forth and code...  =)
goldfingerpunkAuthor Commented:
ok ill try it  is this even close ...
StartingRateNumericUpDown1.Value() = EndingRateNumericUpDown1.Value.MinValue(+2)
goldfingerpunkAuthor Commented:
wait is this better...
 StartingRateNumericUpDown1.Value = (StartingRateNumericUpDown1.Value)
        EndingRateNumericUpDown1.Minimum = +2
        EndingRateNumericUpDown1.Maximum = +10
Mike TomlinsonMiddle School Assistant TeacherCommented:
Getting MUCH closer!

*Your first line isn't actually doing anything.

Start with this:

    Dim currentValue As Integer = StartingRateNumericUpDown1.Value

Now what can you do with "currentValue"?
goldfingerpunkAuthor Commented:
Dim currentvalue As Integer = StartingRateNumericUpDown1.Value
        EndingRateNumericUpDown1.Minimum = (currentvalue + 2)
        EndingRateNumericUpDown1.Maximum = (currentvalue + 10)

my teacher says that it has to automatically update the EndingRateNumericUpDown every time I adjust the StartingRateNumericUpDown
goldfingerpunkAuthor Commented:
Ok I got that part to work finally now the problem is getting it into the multiline text box the first column is Rate(%) the second column is Amount after 5 years and the third column is Amount after 10 years. Now before I did the addendum that the teacher added I did the part in the textbook first so here is what I got so far. I gotta figure out how to get this to appear right.

 ' Declare Variables
        Dim Principal As Decimal
        Dim Amount1 As Decimal
        Dim Rate As Decimal
        Dim Output As String

        ' Retrieve User Input
        Principal = Val(principalTextBox.Text)
        Output = ResultTextBox.Text

        ' Set Output Header
        Output = Output & "Rate(%)" & ControlChars.Tab & "Amount after 5 years" & ControlChars.Tab & ControlChars.Tab & "Amount after 10 years" & ControlChars.CrLf

        ' Calculate Amount
        For rate As Decimal = 5 To 10 Step 1
            Amount1 = _
            Principal * ((1 + rate / 100) ^ 10)
            Output = Output & (rate & ControlChars.Tab & ControlChars.Tab & _
                       String.Format("{0:C}", Amount1) & ControlChars.CrLf)

        ResultTextBox.Text = Output

    End Sub
goldfingerpunkAuthor Commented:
ok I Figured most of it out im just getting lost on the part on how to get the second column (amount after 5 years) and the third column (amount after 10 years) to have the calculations to appear. Because When I try to do two strings it just gives me an error message.
Mike TomlinsonMiddle School Assistant TeacherCommented:
Show me what you've got now...

...and how is StartingRateNumericUpDown1 and EndingRateNumericUpDown1 being incorporated into the code?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.