calculator features

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,

i have created a calculator for weight watchers (a slimming club in london).
it calculates weight.

the form has two textboxes in it and a label and a button. when you click
the button it works out the value of the second textbox (weight after) minus
that of the first one (weight before). the label then says "You gained " and
then the answer. but if you lost weight, it says you gained -15 Kg for
example. how do i make my app realise that it is a negative number and make
the label say "you lost ". dont worry about the maths code. i csn do that.

i hope you understood the question. if not, tell me!

gotta go!
 
Hi Alvo,

Well, if the gain is negative, you have lost weight, right? Change the label in the button event to reflect this.
 
hi,

that was the plan but the boss doesnt like it. she wants it excactly the way
i said it in the origianl question. it is probably extraordinarily difficult
but i need the help i initially wanted

thanks
 
Well, I'm not sure what your boss wants as you didn't really ask a specific question :P However, I forgot to tell you to output the weight as Absolute (Math.Abs) or if will tell you that you lost -15kg (ie gained 15).

As for teaching your app to know if there is a negative number, you do that in the button event (Int32.Parse). There is another way (unecessary awkward way) by handling the second TextBox' KeyPress events. You can then update the label at every keypress without using the button at all.
 
that was the plan but the boss doesnt like it. she wants it excactly the
way
i said it in the origianl question. it is probably extraordinarily
difficult
but i need the help i initially wanted

Morten already answered the question for you - if you don't like his answer,
you'll have to figure it out for yourself...
 
Back
Top