home *** CD-ROM | disk | FTP | other *** search
- unit Main;
-
- { Program copyright (c) 1995 by Charles Calvert }
- { Project Name: ADDALL}
-
- { Demonstrates:
-
- * Creating UNITS that contain utility routines
- * Setting the PUT buttons Default property to True
- to better handle hits on the Enter button.
- * Assigning Hot keys to buttons with an Ampersand (&)
-
- This program uses a utility unit called MATHBOX. It is stored
- in the UNITS subdirectory that ships with this book. Open
- up Options | Environment | Library and make sure the UNITS
- subdirectory is on your Library Path. }
-
-
- interface
-
- uses
- WinTypes, WinProcs,
- Classes, Graphics,
- Controls, Printers,
- Forms, StdCtrls, ExtCtrls;
-
- type
- TForm1 = class(TForm)
- ListBox1: TListBox;
- Edit1: TEdit;
- Label2: TLabel;
- BPut: TButton;
- BCalc: TButton;
- Label1: TLabel;
- BClose: TButton;
- BClear: TButton;
- Panel1: TPanel;
- LResult: TLabel;
- procedure BPutClick(Sender: TObject);
- procedure BCalcClick(Sender: TObject);
- procedure BCloseClick(Sender: TObject);
- procedure BClearClick(Sender: TObject);
- procedure ListBox1DblClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- uses
- MathBox;
-
- {$R *.DFM}
-
- procedure TForm1.BPutClick(Sender: TObject);
- begin
- ListBox1.Items.Add(Edit1.Text);
- Edit1.Text := '';
- Edit1.SetFocus;
- end;
-
- procedure TForm1.BCalcClick(Sender: TObject);
- var
- i: Integer;
- Total: Real;
- begin
- Total := 0;
- for i := 0 to ListBox1.Items.Count - 1 do
- Total := Total + Str2Real(ListBox1.Items.Strings[i]);
- LResult.Caption := Real2Str(Total, 2, 2);
- end;
-
- procedure TForm1.BCloseClick(Sender: TObject);
- begin
- Close;
- end;
-
- procedure TForm1.BClearClick(Sender: TObject);
- begin
- ListBox1.Clear;
- Edit1.SetFocus;
- end;
-
- procedure TForm1.ListBox1DblClick(Sender: TObject);
- begin
- ListBox1.Items.Delete(ListBox1.ItemIndex);
- end;
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- Edit1.Text := '';
- end;
-
- end.
-