home *** CD-ROM | disk | FTP | other *** search
- unit Main;
-
- { Program copyright (c) 1994 by Charles Calvert }
- { Project Name: TWOPOW }
-
- { This program shows:
-
- * How to create For loops.
-
- * How to raise an integer to
- particular power.
-
- Note that you can fairly easily max this program
- out by asking to raising 2 to a power that produces
- a result larger than can be held in a LongInt:
- High(ALongInt). 2 ^ 30 is the most it will
- handle. Try entering 31 while setting OverFlow checking
- on or off by placing or removing the $ before the Q
- shown below. }
-
- {$Q+}
-
- interface
-
- uses
- WinTypes, WinProcs, SysUtils,
- Classes, Graphics, StdCtrls,
- Controls, Printers, Forms;
-
- type
- TForm1 = class(TForm)
- BCalc: TButton;
- Label1: TLabel;
- Edit1: TEdit;
- Label2: TLabel;
- ListBox1: TListBox;
- Label3: TLabel;
- procedure BCalcClick(Sender: TObject);
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.BCalcClick(Sender: TObject);
- var
- i, j, k: LongInt;
- begin
- ListBox1.Clear;
- k := 1;
- j := StrToInt(Edit1.Text);
- for i := 1 to j do begin
- k := k * 2;
- ListBox1.Items.Add(IntToStr(k));
- end;
- Label1.Caption := IntToStr(k);
- end;
-
- end.
-