问题来源: 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 := ;
str := StrUtils.IfThen(a > , 'aaa', 'bbb');
ShowMessage(str); {aaa} a := -;
str := StrUtils.IfThen(a > , 'aaa', 'bbb');
ShowMessage(str); {bbb} a := ;
str := StrUtils.IfThen(a > , 'aaa');
ShowMessage(str); {aaa} a := -;
str := StrUtils.IfThen(a > , 'aaa');
ShowMessage(str); {}
end; procedure TForm1.Button2Click(Sender: TObject);
var
str: string;
num: Integer;
begin
str := '万一';
num := Math.IfThen(str <> '', , );
ShowMessage(IntToStr(num)); {} str := '';
num := Math.IfThen(str <> '', , );
ShowMessage(IntToStr(num)); {} str := '万一';
num := Math.IfThen(str <> '', );
ShowMessage(IntToStr(num)); {} str := '';
num := Math.IfThen(str <> '', );
ShowMessage(IntToStr(num)); {}
end; end.

Delphi 中的 IfThen 函数的更多相关文章

  1. Delphi中使用@取函数地址的问题(转)

    Delphi中使用@取函数地址的问题   例如以下代码:unit Unit1;interfaceuses  Windows, Messages, SysUtils, Variants, Classes ...

  2. Delphi中的四舍五入函数

    一.Delphi中的四舍五入法     四舍五入是一种应用非常广泛的近似计算方法,针对不同的应用需求,其有算术舍入法和银行家舍入法两种.     所谓算术舍入法,就是我们通常意义上的四舍五入法.其规则 ...

  3. delphi中Application.MessageBox函数用法详解

    delphi中Application.MessageBox函数用法详解 Application.MessageBox是TApplication的成员函数,声明如下:functionTApplicati ...

  4. Delphi中的Val函数和iif函数(出错的时候,会有索引值)

    在delphi中Val是一个将字符串转换为数字的函数,Val(S; var V; var Code: Integer)第一个参数是要转换的字符串,第二个参数存放转换后的数字,可以是整数或浮点数,第三个 ...

  5. DELPHI 中的Delay函数,利用GetTickCount和Application.ProcessMessages构建

      作者 关劲松           delphi 开发中有些时候需要停留片刻,等待界面输入,或异步操作完成,如果使用sleep函数的话,整个程序都会停顿,界面还会出现冻结的情况.因此需要自行编写一个 ...

  6. FastReport调用Delphi中的自定义函数(人民币大写金额)mtm

    1. 在 FormCreate 中向FastReprot添加函数 (fPrint)窗口 procedure TfPrint.FormCreate(Sender: TObject); frxReport ...

  7. Delphi中的Rtti函数

    TTypeKind,类型类别,tkclass,tkinteger,tkstring等.类,属性都是一种类型. ttypedata,是一个record包括ttypekind.是一个类的描述.TTypeK ...

  8. 在Delphi中实现HexToStr函数和StrToHex函数

    function TransChar(AChar: Char): Integer; begin '] then Result := Ord(AChar) - Ord(') else Result := ...

  9. delphi中的copy函数和pos函数

    1.copy(‘csdn’,1,2) 返回的结果是 cs 注释: Copy有3个参数,第一个是要处理的字符串,第二个是要截取的开始位置,第三个是截取位数 当第三个参数大于字符长度,那么效果就是取开始位 ...

随机推荐

  1. hbase基础建表语句

    在Hadoop目录下的HBASE下执行命令 ./hbase shell 进入hbase环境 创建hbase 数据库表 create "表名", "字段A",&q ...

  2. atom使用技巧

    文本 批量处理 正则 空格换成换行:Atom替换换行符直接[Ctrl]+[F],然后选择正则,输入\n

  3. Scrapy中集成selenium

    面对众多动态网站比如说淘宝等,一般情况下用selenium最好 那么如何集成selenium到scrapy中呢? 因为每一次request的请求都要经过中间件,所以写在中间件中最为合适 from se ...

  4. @Autowired注解和静态方法

    @Autowired注解入static属性时,出现NullPointerException异常. 使用构造方法可解决: @Component public class Test { private s ...

  5. redhat 7 dns 配置

    dns 配置(安装环境是neokylin7.4) #后为需要在root权限下执行的命令 一.安装 修改配置文件1.需要安装的包 bind . bind-chroot .bind-utils #yum ...

  6. hashmap源码研究

    概述 在官方文档中是这样描述HashMap的: Hash table based implementation of the Map interface. This implementation pr ...

  7. hibernate中怎样配置两个联合属性为唯一约束(非联合主键)

    Annotation中配置: @Table元素包括了一个schema和一个catalog属性,如果需要可以指定相应的值. 结合使用@UniqueConstraint注解可以定义表的唯一约束(uniqu ...

  8. ----Arrow functions----

    Arrow functions Arrow functions表达式相比函数表达式有更短的语法,没有自己的this.argument.super或者new.target. 1.语法规则: 基础语法: ...

  9. shell脚本学习-练习写一个脚本1

    # 1.依次展示/etc/passwd中的用户名和UID.格式如:Hello,$USER,your UID is $UID. # 2.统计一个有多少个用户 #!/bin/bash #Program D ...

  10. 在struts.xml中配置默认action遇到的问题

    初始代码: <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC & ...