本文整理自网络,侵删。
函数 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' //前面补充0Format('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 2009 中 tstrings 与 tstream 的增强
sqlite报错database is locked的解决办法
Delphi 将image组件的图片保存为jpg格式图片方法
更多相关阅读请进入《Delphi》频道 >>