//组清空
var
I:Integer;
begin
for I:=1 to 10 do
if Length((Self.FindComponent('Edit'+IntToStr(I)) as TEdit).Text)>0 then
(Self.FindComponent('Edit'+IntToStr(I)) as TEdit).Clear;
end;
//报信息
var
I:Integer;
begin
for I:=1 to 10 do
if Length((Self.FindComponent('Edit'+IntToStr(I)) as TEdit).Text)=0 then
ShowMessage('编辑框'+(Self.FindComponent('Edit'+IntToStr(I)) as TEdit).Name+'当前内容为空!');
end;
for i:=1 to 10 do
begin
if(trim(editGroup[i].text))='' then //editGroup为edit数组。
showmessage('至少有一个edit为空!');
end;
当然也可以不用数组,这样写:
with Form1 do
for i:=0 to ControlCount-1 do
if (Controls[i] is Tedit) then
if (Controls[i] as Tedit).text:='' then showmessage('至少有一个edit为空!');