How to clear text fields in jpanel?

How do I get this code right? Im using Lazerus which is Delphi based. Cant get it to multiply text fields and then divide by value.

  • The code I'm trying to use is: procedure TForm1.Label1Click(Sender: TObject); begin Cube1.caption := [(Width1.Text)*(Length1.Text)*(Height1.Text)]/1728; end; Just wanting to multiply three text fields that were entered by user then divide that sum by 1728. Thanks,

  • Answer:

    You could have some problems if you are assigning a real value to an integer variable. The result of a "/" division is always a float (double, extended ...). "You are assigning a real value to an integer variable. Change "i: integer" to "i: double" and you are fine." "/ is a floating point division div is an integer division" Source and further information: http://forum.lazarus.freepascal.org/index.php?topic=18942.0

Elijul at Answerbag.com Visit the source

Was this solution helpful to you?

Other answers

I'm Trying this now but cant figure out where to put the / 1728. I can get it to multiply the three strings now just not divide, plz help: procedure TForm1.Cal1Click(Sender: TObject); var W: integer; L: integer; H: integer; begin W := StrToIntDef(Width1.Text, 0); L := StrToIntDef(Length1.Text, 0); H := StrToIntDef(Height1.Text, 0); Cube1.caption := IntToStr(W*L*H); end;

Elijul

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.