How to create a procedure with parameter in delphi?

Hello, now we will discuss about procedure with parameter in delphi 7.0.
Lets see the example below .

Declare your procedure like this:

















procedure validasi(Edit: TEdit);

write the validation procedure like this :
 procedure TForm1.validasi(Edit: TEdit);
begin
    if (trim(Edit.Text)='') then
    begin
    MessageDlg(''+edit.Name+' Tidak Boleh kosong',mtWarning,[mbRetry],0);
    edit.SetFocus;
    abort;
    end;
end;

then call your procedure :
 validasi(EdAlas);
 validasi(EdTinggi);

and the last one you must validate the input too keep the float format like this :
  //#46 = . : #44 = ,
  if not(key in['0'..'9',#8,#46]) then
    key :=#0
  else if(key = #44) and (POS(Key, EdAlas.Text)>0) then 
    key :=#0;
 taraaaa.. you can download the source code here. thanks
Previous
Next Post »