its so simply, create a function just like create a procedure. ok, lets see the example dude!
first, you must declare the function in the private declaration. see the image below.
then, write the function like this :
//functionSee the image below :
function TFrmUtama.hitung(gaji_pokok,jml_anak,status:double):double;
var
total, t_kel, t_anak : Double;
begin
//if jml_anak = 0 then edAnak.Text :='0';
if status=0 then
begin
t_kel := StrToInt(edGapok.Text)/10;
if jml_anak < 3 then
t_anak := jml_anak*250000 //number of child less than 3
else
t_anak := 3*250000; //number of child > 3
end
else
begin //if single
edAnak.Text := '0';
t_kel := 0;
t_anak := 0;
end;
total:=gaji_pokok+t_kel+t_anak;
edtunanak.Text := FloattoStr(t_anak);
//call result.
result:=total;
end;
and then call your function on the submit button. see this image below :
your function should be working now! you can download this source code here. ^^ its easy, isn't?
Sign up here with your email
ConversionConversion EmoticonEmoticon