计算机二级DELPHI函数:Format的使用方法计算机二级考试
文章作者 100test 发表时间 2009:05:07 18:06:55
来源 100Test.Com百考试题网
2009年下半年全国计算机等级考试你准备好了没?考计算机等级考试的朋友,2009年下半年全国计算机等级考试时间是2009年9月19日至23日。更多优质资料尽在百考试题论坛 百考试题在线题库
function Format(const Format: string. const Args: array of const): string. $[SysUtils.pas
功能 返回按指定方式格式化一个数组常量的字符形式
说明 这个函数是我在Delphi中用得最多的函数,现在就列举几个例子给你个直观的理解
\"%\" [索引 \":\"] [\"-\"] [宽度] [\".\" 摘要] 类型
Format(’x=%d’, [12]). //’x=12’ //最普通
Format(’x==’, [12]). //’x= 12’ //指定宽度
Format(’x=%f’, [12.0]). //’x=12.00’ //浮点数
Format(’x=%.3f’, [12.0]). //’x=12.000’ //指定小数
Format(’x=%8.2f’[12.0]) // ’x= 12.00’ .
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). //连接字符串