[菜鸟问题]我这个函数错了吗????(2分)

I

inbreak

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TFormInfo.BtnClick(Sender: TObject);
var
a,b,c,d,e,f,g,h:string;
s:integer;
begin
a:=CmbManager.Text;
b:=CmbChange.Text ;
C:=EditName.Text ;
d:=EditNumber.Text ;
E:=CmbDept.Text ;
F:=CmbJob.Text ;
g:=CmbType.Text ;
h:=MeditDate.Text ;
s:=Checkempty(a,b,c,d,e,f,g,h);
case s of
1:CmbManager.SetFocus ;
2:CmbChangeSalary.SetFocus ;
3:EditName.SetFocus ;
4:EditNumber.SetFocus ;
5:CmbDeptOpt.SetFocus ;
6:CmbJobOpt.SetFocus ;
7:CmbSalaryType.SetFocus ;
8:MEditDate.SetFocus ;
else
Form.ShowModal;
end;
end;

function Checkempty(var a,b,c,d,e,f,g,h:string):integer;
begin
if a='' then Result:= 1;
if b='' then Result:= 2;
if c='' then Result:= 3;
if d='' then Result:= 4;
if e='' then Result:= 5;
if f='' then Result:= 6;
if g='' then Result:= 7;
if h='' then Result:= 8;
end;
 
不提倡这样的做法!!!
s:=Checkempty(a,b,c,d,e,f,g,h);
上面一条语句始终显示一个结果,即只能判断a,b,c,d,e,f,g,h中有一个为''的那个数字!
如果有几个都为空,此方法就不行了!!

给个建议:
你可以定义一个数组,用循环一次就能搞定!不要这么麻烦!!
 
stinglist1.add(a.name,b.name....)
stinglist2.add(a.text,b.text.....)
for i:=0 to stinglist2.count-1 do
begin
if stringList2='' then
Tobject(findCOmpument(stringlist1).SetFocus ;
end

也不知道行不行啊,呵呵
 
多人接受答案了。
 
多人接受答案了。
 
多人接受答案了。
 

Similar threads

S
回复
0
查看
977
SUNSTONE的Delphi笔记
S
S
回复
0
查看
799
SUNSTONE的Delphi笔记
S
I
回复
0
查看
764
import
I
I
回复
0
查看
588
import
I
顶部