If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: Find Minimum and Maximum values

You're entering another invoice in based on a button click event and a textbox i'm assuming? Therefore, these values you're storing for the min and max invoice totals will run out of scope if you're doing it that way. You need to store them outside of the button click event method.

In that kind of setup. That way those values stay in tact even after the code for the button click is finished executing. And you can compare to the new values in the textbox for the next button click event. If you haven't gotten to loops yet, I doubt you're at filestreams or serialization.

Re: Find Minimum and Maximum values

You were right Ace, declaring maxInvoice and minInvoice preserved the invoice data from one input to the next. Once I declared them outside the calculate button event, it started keeping track properly. In addition, I declared the minInvoice as MaxValue, otherwise it always had a 0 in the smallest invoice field. For anyone else needing such basic help, here's the lines I had to add:

Re: Find Minimum and Maximum values

You could even use a nullable type, however, they probably just want you to stick with the normal types. It would eliminate having to set it to the max value as a kind of "safety" mechanism for not staying at 0 for the minimum.