Monday 25 April 2011

Delphi Part II

Listing Delphi

Checkbox:

begin if checkbox1.checked=true then
oli.text:='20000'
else
oli.clear;
end;

utk checkbox berikutnya listingnya sama.

nopolkeypress:

begin
if key=#13 then
begin
if sender=nopol then nama.setfocus;
if sender=nama then checkbox1.setfocus;
end;

Proses:

var a,b,c,d:currency;
begin
if checkbox1.checked=true then
a:strtocurr(oli.text)
else
a:=0
if checkbox2.checked=true then
b:strtocurr(service.text)
else
b:=0
if checkbox3.checked=true then
c:strtocurr(sparepart.text)
else
c:=0
d:=a+b+c;
total.text:=currtostr(d);
end;

Keluar:

begin
if(application.messagebox('Mau Keluar?','info',mb_yesno+32)=IDyes) then
application.terminate;
end;

Bersih:

begin
nopol.clear;
nama.clear;
oli.clear;
service.clear;
total.clear;
checkbox1.checked:=false;
checkbox2.checked:=false;
checkbox3.checked:=false;
nopol.setfocus;
end;

Cara Menambahkan Combobox:
Klik form>isi listing:
jabatan.items.add('Direktur');
jabatan.items.add('Manager');
jabatan.items.add('Karyawan');

Listing Combobox:
properties>events>onclick(2x)

if jabatan.text='Direktur' then
begin
gapok.text:='7000000';
fasilitas.text='Rumah';
end
else
if jabatan.text='Manager' then
begin
gapok.text:='5000000';
fasilitas.text='Mobil';
end
else
if jabatan.text='Karyawan' then
begin
gapok.text:='3000000';
fasilitas.text='Motor';
end
else
gapok.text:='0';
end;
end.


Listing Radio Button:


ketikkan listing di tengah" form:

var
form1:Tform1
a,hasil:real;
implementation
{$R*.dfm}

lalu Listingnya:

begin
if tunai.checked=true then
a:=strtofloat(harga.text);
hasil:=a-(0.1*a);
satuan.text:=floattostr(hasil);
end;

end.

Total:

properties>event>onkeypress>doubleklik>isi listing

begin
if key=#13 then
total.text:=floattostr(strtofloat(harga.text)*strtofloat(jumlah,text));
end;

0 komentar:

Post a Comment