- buatlah aplikasi baru
- tambahkan 2 button
- tambahkan 1 listbox
- button1 untuk mengisi record berupa array
- button2 untuk menampilkan hasil record ke dalam listbox
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
tpegawai=record
nama:string;
alamat:string;
umur:integer;
end;
type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
pegawai : array[0..1] of tpegawai;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
pegawai[0].nama:='bejo';
pegawai[0].alamat:='jember';
pegawai[0].umur:=20;
pegawai[1].nama:='tono';
pegawai[1].alamat:='malang';
pegawai[1].umur:=25;
end;
procedure TForm1.Button2Click(Sender: TObject);
var i:integer;
begin
for i:=0 to 1 do
begin
listbox1.Items.Add('NAMA : '+pegawai[i].nama);
listbox1.Items.Add('ALAMAT : '+pegawai[i].alamat);
listbox1.Items.Add('UMUR : '+inttostr(pegawai[i].umur));
end;
end;
end.
sumber : http://edysoftware.com
0 comments:
Post a Comment