function Format(const Format: string; const Args: array of const): string; 功能 返回按指定方式格式化一个数组常量的字符形式
"%" [索引 ":"] ["-"] [宽度] ["." 摘要] 类型
Format('x=%d', [12]);
Format('x=%3d', [12]);
Format('x=%f', [12.0]);
Format('x=%.*f', [5, 12.0]);
Format('x=%.5d', [12]);
Format('x=%.5x', [12]);
Format('x=%1:d%0:d', [12, 13]);
Format('x=%p', [nil]);
Format('x=%1.1e', [12.0]);
Format('x=%%', []);
可以帮我把上边的解释一下吗?具体的解释出:"%" [索引 ":"] ["-"] [宽度] ["." 摘要] 它们的意思,以及上面每一句Format()语句的意思。我要全面的、详细的、正确的。正确的话立马送分!
"%" [索引 ":"] ["-"] [宽度] ["." 摘要] 类型
Format('x=%d', [12]);
Format('x=%3d', [12]);
Format('x=%f', [12.0]);
Format('x=%.*f', [5, 12.0]);
Format('x=%.5d', [12]);
Format('x=%.5x', [12]);
Format('x=%1:d%0:d', [12, 13]);
Format('x=%p', [nil]);
Format('x=%1.1e', [12.0]);
Format('x=%%', []);
可以帮我把上边的解释一下吗?具体的解释出:"%" [索引 ":"] ["-"] [宽度] ["." 摘要] 它们的意思,以及上面每一句Format()语句的意思。我要全面的、详细的、正确的。正确的话立马送分!
解决方案 »
- 我引用ZLIB单元时,提示我deflate.obj等文件找不到
- 求一个算法
- 学习、交流ERP/MRP经验群 (16301324)
- 菜鸟提问,delphi怎么访问internet上的access数据库啊
- 求日期算法!!!
- 在数据模块中调用另一窗体(非自动创建)中的过程,请教!
- 呵呵~~~~不好意思,问一个极其简单的问题:Delphi中的输入输出语句是什么?
- 我定制的报表无法通过Close()关闭,只有QRPreview1.QRPrinter=nil;Close();才能关闭,请问这样安全吗?
- 怎样打印tpanel中内容?急
- 小谢的问题,从来都很好回答。进来看看吧
- 从二进制文件里读出信息后,怎样把信息存入数据库中的类型为varbinary的字段
- 用ADO时。。。。
类型是里面象d,f,e这些东东。表示传输的类型
这两个是必须的
[宽度]就是这个后面参数代入字符串所占的宽度[索引 ":"] 没用过。help里的解释是An optional argument zero-offset index specifier (that is, the first item has index 0), [index ":"]
u Unsigned decimal. Similar to 'd' but no sign is output.
e Scientific. The argument must be a floating-point value. The value is converted to a string of the form "-d.ddd...E+ddd". The resulting string starts with a minus sign if the number is negative. One digit always precedes the decimal point.The total number of digits in the resulting string (including the one before the decimal point) is given by the precision specifier in the format string梐 default precision of 15 is assumed if no precision specifier is present. The "E" exponent character in the resulting string is always followed by a plus or minus sign and at least three digits.
f Fixed. The argument must be a floating-point value. The value is converted to a string of the form "-ddd.ddd...". The resulting string starts with a minus sign if the number is negative.The number of digits after the decimal point is given by the precision specifier in the format string梐 default of 2 decimal digits is assumed if no precision specifier is present.
g General. The argument must be a floating-point value. The value is converted to the shortest possible decimal string using fixed or scientific format. The number of significant digits in the resulting string is given by the precision specifier in the format string梐 default precision of 15 is assumed if no precision specifier is present.Trailing zeros are removed from the resulting string, and a decimal point appears only if necessary. The resulting string uses fixed point format if the number of digits to the left of the decimal point in the value is less than or equal to the specified precision, and if the value is greater than or equal to 0.00001. Otherwise the resulting string uses scientific format.
n Number. The argument must be a floating-point value. The value is converted to a string of the form "-d,ddd,ddd.ddd...". The "n" format corresponds to the "f" format, except that the resulting string contains thousand separators.
m Money. The argument must be a floating-point value. The value is converted to a string that represents a currency amount. The conversion is controlled by the CurrencyString, CurrencyFormat, NegCurrFormat, ThousandSeparator, DecimalSeparator, and CurrencyDecimals global variables or their equivalent in a TFormatSettings data structure. If the format string contains a precision specifier, it overrides the value given by the CurrencyDecimals global variable or its TFormatSettings equivalent.
p Pointer. The argument must be a pointer value. The value is converted to an 8 character string that represents the pointers value in hexadecimal.
s String. The argument must be a character, a string, or a PChar value. The string or character is inserted in place of the format specifier. The precision specifier, if present in the format string, specifies the maximum length of the resulting string. If the argument is a string that is longer than this maximum, the string is truncated.
x Hexadecimal. The argument must be an integer value. The value is converted to a string of hexadecimal digits. If the format string contains a precision specifier, it indicates that the resulting string must contain at least the specified number of digits; if the value has fewer digits, the resulting string is left-padded with zeros.
Format specifiers have the following form:"%" [index ":"] ["-"] [width] ["." prec] typeA format specifier begins with a % character. After the % come the following, in this order:An optional argument zero-offset index specifier (that is, the first item has index 0), [index ":"]
An optional left justification indicator, ["-"]
An optional width specifier, [width]
An optional precision specifier, ["." prec]
The conversion type character, typeThe following table summarizes the possible values for type:
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); //连接字符串忘了从那copy的了:-)
自己尝试一下