以下过程根据参数S的值,判断执行那一个函数,可是怎样获得函数的返回值?
procedure guochengming(S:integer;S1,S2,S3,S4:string);
begin
case S of
1: hanshu1(S1);
4: hanshu2(S2);
6: hanshu2(S3);
8: hanshu2(S4);
else
showmessage('出现错误!');
end;
end;
procedure guochengming(S:integer;S1,S2,S3,S4:string);
begin
case S of
1: hanshu1(S1);
4: hanshu2(S2);
6: hanshu2(S3);
8: hanshu2(S4);
else
showmessage('出现错误!');
end;
end;
如:
procedure Test(s : string; var Result1 : string);
begin
case S of
1: Result1 := hanshu1(S1);
4: Result1 := hanshu2(S2);
6: Result1:=hanshu2(S3);
8: Result1:= hanshu2(S4);
else begin
showmessage
Result1 := '';
end;
end;
以上是在过程中返回值
另外可以定义函数 来返回想要地值
function Test(s : string): string;
begin case S of
1: Result := hanshu1(S1);
4: Result := hanshu2(S2);
6: Result:=hanshu2(S3);
8: Result:= hanshu2(S4);
else begin
showmessage
Result := '';
end;
end;
建议lz看下基础方面的书籍~~~~~~~~~~~