home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programming Unleashed / Delphi_Programming_Unleashed_SAMS_Publishing_1995.iso / chap11 / moneyint / main.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-03-21  |  1.3 KB  |  66 lines

  1. unit Main;
  2.  
  3. { Program copyright (c) 1995 by Charles Calvert }
  4. { Project Name: MoneyInt }
  5.  
  6. { When working with dollar and cents, it is easy to
  7.   create rounding errors. As a result, your program
  8.   can easily make invalid financial calculations.
  9.   This program demonstrates using the COMP type to
  10.   accurately calculate finincial figures. Make sure
  11.   the MATHBOX unit is on your Library Path in the
  12.   Options | Environment | Library menu choice. }
  13.  
  14. {$N+}
  15.  
  16. interface
  17.  
  18. uses
  19.   WinTypes, WinProcs, Classes,
  20.   Graphics, Controls, Forms,
  21.   StdCtrls, ExtCtrls;
  22.  
  23. type
  24.   TForm1 = class(TForm)
  25.     Edit1: TEdit;
  26.     BCalc: TButton;
  27.     BClose: TButton;
  28.     Panel1: TPanel;
  29.     Label1: TLabel;
  30.     procedure BCalcClick(Sender: TObject);
  31.     procedure FormCreate(Sender: TObject);
  32.     procedure BCloseClick(Sender: TObject);
  33.   end;
  34.  
  35. var
  36.   Form1: TForm1;
  37.  
  38. implementation
  39.  
  40. uses
  41.   MathBox;
  42.  
  43. {$R *.DFM}
  44.  
  45. procedure TForm1.BCalcClick(Sender: TObject);
  46. var
  47.   C: Comp;
  48. begin
  49.   C := Str2Pennies(Edit1.Text);
  50.   C := C + 120;
  51.   Label1.Caption := Pennies2Dollars(C);
  52. end;
  53.  
  54. procedure TForm1.FormCreate(Sender: TObject);
  55. begin
  56.   Edit1.Text := '';
  57.   Label1.Caption := '';
  58. end;
  59.  
  60. procedure TForm1.BCloseClick(Sender: TObject);
  61. begin
  62.   Close;
  63. end;
  64.  
  65. end.
  66.