[ 482 查看 / 100 回复 ]
baseyueliang
bdmh
mysterx
sanguomi
chys3584
lgx0914
function TForm1.GetValue2(var s: string): Boolean;begin Result := True; ShowMessage('af');//加上这行再试试,会发现没有执行 s := 'World'; end;
starluck
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private function GetTrue: Boolean; function GetValue1(var s: string): Variant; function GetValue2(var s: string): Boolean; public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}function TForm1.GetTrue: Boolean;begin Result := True;end;function TForm1.GetValue1(var s: string): Variant;begin s := 'World'; Result := True;end;function TForm1.GetValue2(var s: string): Boolean;begin Result := True; s := 'World';end;procedure TForm1.Button1Click(Sender: TObject);var s: string;begin if GetTrue or GetValue1(s) then ShowMessage('Hello ' + s);end;procedure TForm1.Button2Click(Sender: TObject);var s: string;begin if GetValue2(s) or (GetTrue) then ShowMessage('Hello ' + s);end;end.
fengjsSoft