Minggu, 21 Juni 2015

Memasukkan atau menambah data nama dengan menggunakan array.


















List Program
Listing Program
unit Unit2;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Edit1: TEdit;
    LBData: TListBox;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var i:integer;
  nama1,nama2:array[1..5] of string;
  s:string;

begin
  s:= inputbox('input data','masukkan jumlah data :','0');
  for i:= 1 to strtoint(s) do
    begin
    nama1[i]:=inputbox('data ke:'+inttostr(i),'nama depan','');
    nama2[i]:=inputbox('data ke:'+inttostr(i),'nama belakang','');
    LBData.ITEMS.Add(nama1[i]+' '+nama2[i]);
    edit1.Text:=inttostr(LBData.Items.Count);
    end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  LBData.Clear;
  edit1.Text:='';
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  CLOSE;
end;

end.

Hasil Running




0 komentar:

Posting Komentar

Categories

Total Tayang

Jam

Kalender Islam

Diberdayakan oleh Blogger.

Popular Posts

Pengikut