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.
goldfingerpunkAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
Beautiful!...

"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?
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Handle the ValueChanged() event of the starting rate NumericUpDown and change the ending rate min/max values accordingly:
http://msdn.microsoft.com/en-us/library/system.windows.forms.numericupdown.valuechanged.aspx
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

0
 
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
        Next
0
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:
http://msdn.microsoft.com/en-us/library/system.windows.forms.numericupdown.value.aspx

Now add 2 to that and set the Minimum() property:
http://msdn.microsoft.com/en-us/library/system.windows.forms.numericupdown.minimum.aspx

...and add 10 to it and set the Maximum() property:
http://msdn.microsoft.com/en-us/library/system.windows.forms.numericupdown.maximum.aspx

YOU CAN DO IT!  Go forth and code...  =)
0
 
goldfingerpunkAuthor Commented:
ok ill try it  is this even close ...
StartingRateNumericUpDown1.Value() = EndingRateNumericUpDown1.Value.MinValue(+2)
0
 
goldfingerpunkAuthor Commented:
wait is this better...
 StartingRateNumericUpDown1.Value = (StartingRateNumericUpDown1.Value)
        EndingRateNumericUpDown1.Minimum = +2
        EndingRateNumericUpDown1.Maximum = +10
0
 
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"?
0
 
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
0
 
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)
        Next
       



        ResultTextBox.Text = Output

    End Sub
0
 
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.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Show me what you've got now...

...and how is StartingRateNumericUpDown1 and EndingRateNumericUpDown1 being incorporated into the code?
0
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.