Berikut Gambaran Form Latihan yang akan kita buat:


Properti yang digunakan:
- Button (2)
- Edit (2)
- Panel (1)
- RadioButton (1)
- ListBox (1)
- ComboBox (1)
- Label (1)


Setelah anda menambahkan properti diatas, anda dapat mengisi source kode berikut kemasing masing properti:

     Masukan ke Button1(Tambah)
procedure TForm1.Button1Click(Sender: TObject);
begin
if(Edit1.Text <> '') and
(listbox1.Items.IndexOf(Edit1.Text) < 0 ) then
begin
  listbox1.Items.Add(Edit1.Text);
  combobox1.Items.Add(Edit1.Text);
  combobox1.ItemIndex :=
  combobox1.Items.IndexOf(combobox1.Items[combobox1.Itemindex]);
    end else
      messagedlg('Control edit kosong atau ' + ' Mengandung string yang sudah ada', mtError, [mbOK], 0);


end;

     Masukan ke ListBox:
procedure TForm1.ListBox1Click(Sender: TObject);
var phrase, str1, str2 :string;
  pilih, lihat : integer;
begin
pilih := 0;
for lihat := 0 to listbox1.Items.Count-1 do
if listbox1.Selected[lihat] then
begin
  inc (pilih);
  if pilih = 1 then
  begin
    str1 := listbox1.Items.Strings[lihat];
    str2 := str1;
  end else
  if pilih = 2 then
  begin
    str1 := str1 + ' dan ' + listbox1.Items.Strings[lihat];
    str2 := str2 + ', ' + listbox1.Items.Strings[lihat];
  end else
  begin
    str1 := str2 +' dan ' + listbox1.Items.Strings[lihat];
    str2 :=  str2 + ', ' +listbox1.Items.Strings[lihat];
  end;
end;
if pilih > 0 then
phrase := str1 + ' terletak '
else phrase := ' Tidak ada apa-apa';

  phrase := phrase + RadiGroup1.Items[RadiGroup1.Itemindex];
  phrase := phrase + ' ' + combobox1.Text;
  label1.Caption := phrase;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
if(Edit1.Text <> '') and
(listbox1.Items.IndexOf(Edit1.Text) < 0 ) then
begin
  listbox1.Items.Add(Edit1.Text);
  combobox1.Items.Add(Edit1.Text);
  combobox1.ItemIndex :=
  combobox1.Items.IndexOf(combobox1.Items[combobox1.Itemindex]);
    end else
      messagedlg('Control edit kosong atau ' + ' Mengandung string yang sudah ada', mtError, [mbOK], 0);


end;

     Dan yang terakhir masukan ke Button2(Close)
procedure TForm1.Button2Click(Sender: TObject);
begin
application.Terminate;
end;

Diposting oleh Unknown

0 komentar:

Visit the Site
MARVEL and SPIDER-MAN: TM & 2010 Marvel Characters, Inc. Motion Picture © 2010 Columbia Pictures Industries, Inc. All Rights Reserved. 2010 Sony Pictures Digital Inc. All rights reserved. Provided By Free Website Templates | Freethemes4all.com
Free Website templatesFree Flash TemplatesFree joomla templatesSEO Web Design AgencyMusic Videos OnlineFree Wordpress Themes Templatesfreethemes4all.comFree Blog TemplatesLast NewsFree CMS TemplatesFree CSS TemplatesSoccer Videos OnlineFree Wordpress ThemesFree Web Templates