Rabu, 13 April 2011

PROGRAM PERKALIAN AND PENJUMLAHAN DENGAN STRINGGRID

unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, XPMan, StdCtrls, Grids;
type
  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    Button1: TButton;
    Button2: TButton;
    XPManifest1: TXPManifest;
    procedure FormPaint(Sender: TObject);
    procedure FormResize(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
{$R *.dfm}

//Untuk animasi form
procedure TForm1.FormPaint(Sender: TObject);
Var i : integer;
begin
For i := 1 to 5000 Do
Begin
Canvas.Pen.Color := clBlue;
Canvas.Pen.Style := psDashDot;
Canvas.MoveTo(ClientWidth div 2, ClientHeight div 2);
Canvas.LineTo(random(ClientWidth),random(ClientHeight));
end;
end;

//pemanggilan animasi form
procedure TForm1.FormResize(Sender: TObject);
begin
 Invalidate;
end;

procedure TForm1.FormCreate(Sender: TObject);
var i,kolom,baris :integer;
begin
for kolom:=1 to 10 do
StringGrid1.Cells[kolom,0] := IntToStr(kolom);

for baris:=1 to 10 do
StringGrid1.Cells[0,baris] := IntToStr(baris);


end;

procedure TForm1.Button1Click(Sender: TObject);
var kolom,baris:integer;
begin
StringGrid1.Cells [0,0]:=' + ';

for kolom :=1 to 10 do
for baris := 1 to 10 do
StringGrid1.Cells [kolom,baris]:= IntToStr(kolom+baris);

end;

procedure TForm1.Button2Click(Sender: TObject);
var kolom,baris:integer;
begin
StringGrid1.Cells [0,0]:=' * ';
for kolom :=1 to 10 do
for baris := 1 to 10 do
StringGrid1.Cells [kolom,baris]:= IntToStr(kolom*baris);
end;

end.

thank's...

Selamat Mencoba...

Tidak ada komentar:

Posting Komentar