Recent

Author Topic: Use radio buttons and formulas  (Read 4097 times)

sellend2195

  • Newbie
  • Posts: 1
Use radio buttons and formulas
« on: April 09, 2015, 05:47:17 pm »
Hello I am new to Pascal language, but my company is asking that I learn.

Right now I would like to create a window with three radio buttons that we can select based on different materials (i.e. Copper, steel, graphite) and the output would result in a calculation based on a yield from another software.

I am sure this is a little confusing so for example, we create a steel product in our in house software and it outputs a yield of .982 sheets. Then we have to take a calculator and by hand calculate the actual yield (yield from in house program/12/20/100*250). But if they use another material (copper) it is a different calculation (yield from in house program/9/20/62.5*250).

Right now I have two text fields: one that has the in house number and one that I want to have my calculated number. With the Procedure below, I was just trying to test with a straight formula if I could get a real number to be the result .(982 steel yield would result in .0102 actual yield) and then work on getting the radio buttons to work.

TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
VAR I: Integer;
    Itotal: Real;
begin
  I:=StrtoInt(Edit1.TEXT);
  Itotal:=Round(I/12/20/100*250);
  edit2.TEXT:=StrtoFloat(Itotal);
end;

end.                                           

Any help you can provide would be greatly appreciated.

Thank you,

Daniel

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Use radio buttons and formulas
« Reply #1 on: April 09, 2015, 07:03:33 pm »
The attached project shows a simple way to display your calculation.

What makes you think that
   inhouseyield/12/20/100*250
is the correct formula for producing 0.0102 from 0.982?

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Use radio buttons and formulas
« Reply #2 on: April 16, 2015, 01:39:43 am »
you have 2 monitors don't you howard? just out of curiosity how did you end up with the 96.274509 value you used?
« Last Edit: April 16, 2015, 01:52:53 am by taazz »
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Use radio buttons and formulas
« Reply #3 on: April 16, 2015, 09:48:33 am »
I did what sellend2195 says he does. I took a (cheap, 8 digit) calculator and divided 0.982 by 0.0102.
How do you deduce that I have two monitors?

wp

  • Hero Member
  • *****
  • Posts: 11923
Re: Use radio buttons and formulas
« Reply #4 on: April 16, 2015, 10:00:50 am »
Quote from: howardpc
How do you deduce that I have two monitors?

Probably because the "Left" of the form is negative.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Use radio buttons and formulas
« Reply #5 on: April 16, 2015, 10:23:15 am »
How do you deduce that I have two monitors?
Quote from: howardpc
How do you deduce that I have two monitors?

Probably because the "Left" of the form is negative.
bingo! correct with the first guess!


I did what sellend2195 says he does. I took a (cheap, 8 digit) calculator and divided 0.982 by 0.0102.
Sellend2195 said that the formula was X/12/20/100*250 = Y and also said that when X = 0.982 then Y = 0.0102 now simplifying the formula would result in X/96 = Y at least that is what I come up with.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

 

TinyPortal © 2005-2018