【求助】delphi 如何定义函数返回多个值,高手进~~急,在线等~~~(50)

G

gu_leilei

Unregistered / Unconfirmed
GUEST, post messages is not allowed!
#1
有张表如下:x y a1 r1 a2 r2A y<=300 0.1 0.3 0.5 0.8......现在要在delphi环境里定义一个函数,函数功能是根据确定x,y 返回a1 r1 a2 r2的值,求大虾帮忙定义能返回这4个值的函数?
 
X

xiaojun5556

Unregistered / Unconfirmed
GUEST, post messages is not allowed!
#2
先定义一个记录;然后把定义函数的返回类型定义为你的记录;如记录type tmyrec=record a1 : string;
r1 : string;
a2 :string;
r2 :string;
end;
函数function myfun : tmyrec;
begin
result.a1 := '1';
result.r1 := '2';
result.a2 := '3';
result.r2 := '4';
end;
使用procedure Tform1.Button1Click(Sender: TObject);var myrec : tmyrec;
begin
myrec := myfun;
edit1.text := myrec.a1;
. . edit4.text := myrec.r2;
end;
 
L

luoyanqing119

Unregistered / Unconfirmed
GUEST, post messages is not allowed!
#3
把返回值装在stringlist里就好了。
 
L

lht123

Unregistered / Unconfirmed
GUEST, post messages is not allowed!
#4
定义成动态数组 也可以。
 
H

hs-kill

Unregistered / Unconfirmed
GUEST, post messages is not allowed!
#5
用var参数不就好了procedure aa(x,y:integer;
var r1,a1,r2,a2:double);var a,b,c,d:double;
begin
aa(1,1,a,b,c,d);
showmessage(format('%f,%f,%f,%f',[a,b,c,d]));
end;
 
E

eloveme

Unregistered / Unconfirmed
GUEST, post messages is not allowed!
#6
procedure XXX(const x,y:integer;out r1,a1,r2,a2:double)begin
r1 := 0;
a1 := 0;
r2 := 0 ;
a2 := 0;
end;
 
Top Bottom