Minggu, 01 Januari 2012

Script Program Matriks Delphi (penjumlahan & pengurangan)

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, StdCtrls, Buttons, XPMan;

type
  TForm1 = class(TForm)
    XPManifest1: TXPManifest;
    GroupBox1: TGroupBox;
    StringGrid1: TStringGrid;
    StringGrid2: TStringGrid;
    GroupBox2: TGroupBox;
    StringGrid3: TStringGrid;
    Button1: TButton;
    Button2: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Button4: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

var mx1:array[0..2,0..2] of integer;
var mx2:array[0..2,0..2] of integer;
var mx3:array[0..2,0..2] of integer;
var m1a,m1b:integer;
var m2a,m2b:integer;
var m3a,m3b:integer;
begin

begin
for m1a:=0 to StringGrid1.RowCount-1 do
begin
for m1b:=0 to StringGrid1.ColCount-1 do
begin
mx1[m1a,m1b]:=StrToInt(StringGrid1.Cells[m1a,m1b]);
end
end
end;

begin
for m2a:=0 to StringGrid2.RowCount-1 do
begin
for m2b:=0 to StringGrid2.ColCount-1 do
begin
mx2[m2a,m2b]:=StrToInt(StringGrid2.Cells[m2a,m2b]);
end
end
end;

begin
for m3a:=0 to StringGrid1.RowCount-1 do
begin
for m3b:=0 to StringGrid1.ColCount-1 do
begin
mx3[m3a,m3b]:=mx1[m3a,m3b]+mx2[m3a,m3b];
StringGrid3.Cells[m3a,m3b]:=IntToStr(mx3[m3a,m3b]);
end
end
end;
end;

procedure TForm1.Button2Click(Sender: TObject);

var mx1:array[0..2,0..2] of integer;
var mx2:array[0..2,0..2] of integer;
var mx3:array[0..2,0..2] of integer;
var m1a,m1b:integer;
var m2a,m2b:integer;
var m3a,m3b:integer;
begin

begin
for m1a:=0 to StringGrid1.RowCount-1 do
begin
for m1b:=0 to StringGrid1.ColCount-1 do
begin
mx1[m1a,m1b]:=StrToInt(StringGrid1.Cells[m1a,m1b]);
end
end
end;

begin
for m2a:=0 to StringGrid2.RowCount-1 do
begin
for m2b:=0 to StringGrid2.ColCount-1 do
begin
mx2[m2a,m2b]:=StrToInt(StringGrid2.Cells[m2a,m2b]);
end
end
end;

begin
for m3a:=0 to StringGrid1.RowCount-1 do
begin
for m3b:=0 to StringGrid1.ColCount-1 do
begin
mx3[m3a,m3b]:=mx1[m3a,m3b]-mx2[m3a,m3b];
StringGrid3.Cells[m3a,m3b]:=IntToStr(mx3[m3a,m3b]);
end
end
end;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
close
end;

end.
»»  READMORE...

Program Luas Segitiga Delphi

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, jpeg, ExtCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Button1: TButton;
    Image1: TImage;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var a,t,l:real;
begin
a:=strtofloat(edit1.Text);
t:=strtofloat(edit2.Text);
l:=a*t*0.5;
edit3.Text:=floattostr(l);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
form1.Close
end;

end.
»»  READMORE...

Baner Lomba