function 函數回傳值 |
答題得分者是:malanlk
|
sundy6719
初階會員 發表:136 回覆:78 積分:42 註冊:2002-07-10 發送簡訊給我 |
|
l630521
資深會員 發表:15 回覆:349 積分:372 註冊:2003-02-17 發送簡訊給我 |
|
malanlk
尊榮會員 發表:20 回覆:694 積分:577 註冊:2004-04-19 發送簡訊給我 |
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TFoo = record FValueA: Integer; FValueB: Integer; end; TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } function FooReturn1(A,B:Integer): TFoo; function FooReturn2(var A,B: Integer): Boolean; end; var Form1: TForm1; implementation {$R *.dfm} function TForm1.FooReturn1(A,B:Integer): TFoo; begin Result.FValueA := A; Result.FValueB := B; end; function TForm1.FooReturn2(var A,B:Integer): Boolean; begin A := A 1; B := B 1; Result := True; end; procedure TForm1.Button1Click(Sender: TObject); var xFoo: TFoo; xA,xB: Integer; begin xFoo := FooReturn1(12,20); ShowMessage(Format('A=%d,B=%d',[xFoo.FValueA,xFoo.FValueB])); xA := 10; xB := 15; if FooReturn2(xA,xB) then ShowMessage(Format('xA=%d,xB=%d',[xA,xB])); end; end.這是兩種 傳回多值 的方式 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |