Re:Re: Printing calculated results


[ Delphi Forum ] [ Delphi Tutorials -- by DelphiLand ]

Posted by Lionel on June 25, 2003

In Reply to: Re: Printing calculated results posted by webmaster Guido on June 24, 2003:

This is an example of where I compute the Sine, Cosine, Tangent, Secant, Cosecant and Cotangent of an angle and then display the results on the Form. This is OK and works just fine but there are times when I would like to have a hardcopy.--- I would like to use a Print Button to make a hardcopy of the Sine, Cosine, Tangent, etc. The following code will display the results on the form but I would like to print out a hardcopy. I may not be making myself clear regarding this and if so, let me know.

procedure TForm1.calcClick(Sender: TObject);
var
  Degree, Minute, Second: integer;
  DecimalAngle, Rad, X,
  Sine, Cosine, Tangent, Secant,
  Cosecant, Cotangent, LogSine: double;
begin
  try
     Degree := StrToInt(deg.Text);
     Minute := StrToInt(min.Text);
     Second := StrToInt(sec.Text);
  except
     ShowMessage('Whoops, error in angle input');
     exit;
  end;

  DecimalAngle := Degree + (Minute / 60) + (Second / 3600);
  Rad := DecimalAngle * pi / 180;
  X := Rad;
  
  Sine   := Sin(Rad);
  Cosine := Cos(Rad);
  Tangent:= Tan(Rad);

  Secant := 1/cos(Rad);
  Cosecant:=1/Sin(Rad);
  Cotangent:=1/Tan(Rad);
  LogSine:=(exp(x) - exp(-x))/2;
  
  Edit4.Text := FloatToStr(DecimalAngle);
  Edit5.Text := FloatToStr(Rad);

  Edit1.Text :=FloatToStr(Sine);
  Edit2.Text:= FloatToStr(Cosine);
  Edit3.Text:= FloatToStr(Cosine);

  Edit6.Text := FloatToStr(secant);
  EDIT7.Text:= FloatToStr(Cosecant);
  Edit8.Text:= FloatToStr(Cotangent);
  Edit9.Text:= FloatToStr(LogSine);
end;

end.

Related Articles and Replies:


 


[ Delphi Forum ] [ Delphi Tutorials -- by DelphiLand ]