加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Delphi 中的 IfThen 函数

发布时间:2020-12-15 09:53:06 所属栏目:大数据 来源:网络整理
导读:问题来源:?http://www.cnblogs.com/del/archive/2008/11/14/1120015.html#1370413 StrUtils 单元和 Math 单元 分别有一个 IfThen 函数(注意参数是数字还是字符串),举例: ? StrUtils 单元和 Math 单元 分别有一个 IfThen 函数,举例: unit Unit1; interface

问题来源:?http://www.cnblogs.com/del/archive/2008/11/14/1120015.html#1370413

StrUtils 单元和 Math 单元 分别有一个 IfThen 函数(注意参数是数字还是字符串),举例:

?

StrUtils 单元和 Math 单元 分别有一个 IfThen 函数,举例:
unit Unit1;
 
interface
 
uses
  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);
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
uses StrUtils,Math;
 
procedure TForm1.Button1Click(Sender: TObject);
var
  a: Integer;
  str: string;
begin
  a := 1;
  str := StrUtils.IfThen(a > 0,aaa,bbb);
  ShowMessage(str); {aaa}
 
  a := -1;
  str := StrUtils.IfThen(a > 0,bbb);
  ShowMessage(str); {bbb}
 
  a := 1;
  str := StrUtils.IfThen(a > 0,aaa);
  ShowMessage(str); {aaa}
 
  a := -1;
  str := StrUtils.IfThen(a > 0,aaa);
  ShowMessage(str); {}
end;
 
procedure TForm1.Button2Click(Sender: TObject);
var
  str: string;
  num: Integer;
begin
  str := 万一;
  num := Math.IfThen(str <> ‘‘,99,11);
  ShowMessage(IntToStr(num)); {99}
 
  str := ‘‘;
  num := Math.IfThen(str <> ‘‘,11);
  ShowMessage(IntToStr(num)); {11}
 
  str := 万一;
  num := Math.IfThen(str <> ‘‘,99);
  ShowMessage(IntToStr(num)); {99}
 
  str := ‘‘;
  num := Math.IfThen(str <> ‘‘,99);
  ShowMessage(IntToStr(num)); {0}
end;
 
end.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读