Solved

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

Posted on 2011-03-23
11
410 Views
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.
0
Comment
Question by:goldfingerpunk
  • 6
  • 5
11 Comments
 
LVL 85

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

Author Comment

by:goldfingerpunk
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
        Next
0
 
LVL 85

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:
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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

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

Author Comment

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

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

Author Comment

by:goldfingerpunk
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
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 35203451
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
 

Author Comment

by:goldfingerpunk
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)
        Next
       



        ResultTextBox.Text = Output

    End Sub
0
 

Author Comment

by:goldfingerpunk
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.
0
 
LVL 85

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

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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.

792 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