Delphi 字符串操作之格式化


本文整理自网络,侵删。

 
函数 function Format(const Format: string; const Args: array of const): string;  需引用 SysUtils.pas
功能 返回按指定方式格式化一个数组常量的字符形式
说明 这个函数是我在Delphi中用得最多的函数,现在就列举几个例子给你个直观的理解
"%" [索引 ":"] ["-"] [宽度] ["." 摘要] 类型
Format('x=%d', [12]); //'x=12' //最普通
Format('x=%3d', [12]); //'x= 12' //指定宽度
Format('x=%f', [12.0]); //'x=12.00' //浮点数
Format('x=%.3f', [12.0]); //'x=12.000' //指定小数
Format('x=%.*f', [5, 12.0]); //'x=12.00000' //动态配置
Format('x=%.5d', [12]); //'x=00012' //前面补充0
Format('x=%.5x', [12]); //'x=0000C' //十六进制
Format('x=%1:d%0:d', [12, 13]); //'x=1312' //使用索引
Format('x=%p', [nil]); //'x=00000000' //指针
Format('x=%1.1e', [12.0]); //'x=1.2E+001' //科学记数法
Format('x=%%', []); //'x=%' //得到"%"
S := Format('%s%d', [S, I]); //S := S + StrToInt(I); //连接字符串

相关阅读 >>

Delphi readprocessmemory writeprocessmemory读写内存

Delphi firedac 获取 insert 记录的自增 id

Delphi xe android 程序切换到后台及从后台切换到前台实现

Delphi listview用法

Delphi 实现定时功能

Delphi 控制n个字符间距空格

Delphi搜索文件夹和文件

Delphi 删除动态数组的指定元素

Delphi 文件夹操作

decodedatetime:将一个tdatetime变量拆分成它的日期/时间 部分

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...