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

Posted on 2011-03-23
Medium Priority
Last Modified: 2013-11-27
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.
Question by:goldfingerpunk
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 35202525
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


Author Comment

ID: 35203222
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
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 35203244
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...  =)
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 35203320
ok ill try it  is this even close ...
StartingRateNumericUpDown1.Value() = EndingRateNumericUpDown1.Value.MinValue(+2)

Author Comment

ID: 35203339
wait is this better...
 StartingRateNumericUpDown1.Value = (StartingRateNumericUpDown1.Value)
        EndingRateNumericUpDown1.Minimum = +2
        EndingRateNumericUpDown1.Maximum = +10
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 35203416
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"?

Author Comment

ID: 35203441
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
LVL 86

Accepted Solution

Mike Tomlinson earned 2000 total points
ID: 35203451

"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?

Author Comment

ID: 35203464
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

Author Comment

ID: 35203515
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.
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 35203524
Show me what you've got now...

...and how is StartingRateNumericUpDown1 and EndingRateNumericUpDown1 being incorporated into the code?

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question