1/1页1 跳转到查看:263
发新话题 回复该主题

两个delphi函数:ifthen和iif

两个delphi函数:ifthen和iif

这两个函数都是通过Boolean表达式获取值的方法。
应用方法如下:

var
  Form1: TForm1;

implementation
uses
  Math, IdGlobal;
{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  iReturn: Integer;
begin
  iReturn := IfThen(100>10, 100, 0);
  ShowMessage(IntToStr(iReturn));

  iReturn := iif(100<10, 100, 0);
  ShowMessage(IntToStr(iReturn));
end;


显示的结果:
100
0

效果一样的,只不过要注意:ifthen是在Math单元中,而iif在IdGlobal单元中。

TOP

 
1/1页1 跳转到
发表新主题 回复该主题