Components of checking the Class Components

Components of checking the Class Components
In a program usually make it clear inputan form before the latest data on inputs. This is normally done to help the user distinguish between the input data with new data input koreks.
When we use the components so TEdit we often use the command edit1.text :=''; means edit1 column blank value. sebgai example we will menginput student data before the new data submitted, we will clear the form input fields with the first.

eNim.text:='';
eNama.text:='';
eAlamat.text:='';

and so forth. techniques such as this is not why, but sometimes make when we use saturated many tedit in a form inputan. so that the necessary rigor in order to provide one by one.
There may be a function can overcome this problem. so we do not need to give commands on a component Tedit to clear the value. We undertake sufficient component of the class, if the component is Tedit then we fill with the value''or empty
The following functions that we can use.

Function kosong_edit(form:tform;para:byte):boolean;
var
i:byte;
com:tcomponent;
begin
for i:=0 to form.ComponentCount-1 do
begin
com:=form.Components[i];
if com is tedit then
begin
with com as tedit do
begin
case para of
1:
begin
text:='';
enabled:=true;
end;
2:
begin
enabled:=true;
text:='yes';
end;
end;
end;
end;
end;
end;

to use this function, we can use the existing parameters

kosong_edit (form1, 1); or kosong_edit (form1, 2);



more complete listing can use the following information:

unit Unit1.
interface

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

type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
function kosong_edit(form:tform;para:byte):boolean;
var i:byte;
com:tcomponent;
begin
for i:=0 to form.ComponentCount-1 do
begin
com:=form.Components[i];
if com is tedit then
begin
with com as tedit do
begin
case para of
1:
begin
text:='';
enabled:=true;
end;
2:
begin
enabled:=true;
text:='yes';
end;

end;
end;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
kosong_edit(form1,1);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
kosong_edit(form1,2);
end;

end

then delphi components see below

Postingan populer dari blog ini

vb6 msflexgrid

Tutorial Visual Basic 6.0 : Listbox in VB6

Select Single Cell in MSHFlexgrid