FB

Showing posts with label Delphi. Show all posts
Showing posts with label Delphi. Show all posts

Membuat Array Baris dan Kolom

Sunday, March 14, 2010




Berikut ini merupakan cara Membuat Array Matriks Baris dan Kolom secara Sedenhana yang saya buat
Ni Listingnya:


procedure TForm1.Button1Click(Sender: TObject);
var
Data : array of array of integer;
Baris, kolom : word;
begin
// Menentukan panjang array untuk setiap dimensi
SetLength( Data,
StrToInt(baris_array.Text), // panjang dimensi 1
StrToInt(kolom_array.Text)); // panjang dimensi 2
//pemasukkan data ke array
for Baris := 0 to StrToInt(baris_array.Text)-1 do
for Kolom := 0 to StrToInt(kolom_array.Text)-1 do
Data[Baris,kolom] := Baris+kolom;
// mengosongkan data pd Listbox
ListBox1.Clear;
//menampilkan data array
for Baris := 0 to StrToInt(baris_array.Text)-1 do
for Kolom := 0 to StrToInt(kolom_array.Text)-1 do
Listbox1.Items.Add('[' + IntToStr(Baris) + ',' + IntToStr(Kolom)+']=' +
IntToStr(Data[Baris,kolom]));
end;
end.

Delphi Membuat Kalkulator Sederhana

Wednesday, March 10, 2010





Kalkulator Sederhana yang pernah Saya Buat
Ni Listingnya:


var
Form1: TForm1;
a,b,z:double;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
a:=StrToFloat(txtVal1.Text);
b:=StrToFloat(txtVal2.Text);
z:=a+b;

ShowMessage(FloatToStr(z));
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
a:=StrToFloat(txtVal1.Text);
b:=StrToFloat(txtVal2.Text);
z:=a-b;

ShowMessage(FloatToStr(z));
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
a:=StrToFloat(txtVal1.Text);
b:=StrToFloat(txtVal2.Text);
z:=a*b;

ShowMessage(FloatToStr(z));
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
a:=StrToFloat(txtVal1.Text);
b:=StrToFloat(txtVal2.Text);
z:=a/b;

ShowMessage(FloatToStr(z));
end;

end.