델파이
델파이에서의 VB의 ByRef같이 참조로 변수를 넘기는 방법
띠리
2007. 12. 12. 20:09
델파이에서의 VB의 ByRef같이 참조로 변수를 넘기는 방법
unit Unit1;
interface
uses
Forms, StdCtrls, Controls, Classes;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
procedure RefParam(var sParam : string);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
sTest : string;
begin
sTest := '';
RefParam(sTest);
Button1.Caption := sTest;
end;
procedure TForm1.RefParam(var sParam: string);
begin
sParam := '참조변수';
end;
end.
함수의 파라미터를 정의할 때 var를 쓰면 그 파라미터는 참조형식으로 된다.