我想要更新“更新报告 (1 0f 5)”之类的文本。我认为 format 函数可以帮助我做到这一点。我想要这样的东西
string := Format('Updating report ( %d of %d, [1], [2])', loop, count );
但这是不可能的。我可以选择将循环和计数存储在字符串中并连接所有内容。但还有其他方法可以实现我想要的吗?
最佳答案
你的语法错误。第二个参数为Format
是一个包含参数的开放数组。因此,您需要将参数列表包装在所谓的 open array constructor 中。 .
An open array constructor is a sequence of expressions separated by commas and enclosed in brackets.
所以,编写这样的代码:
str := Format('Updating report (%d of %d)', [loop, count]);
关于delphi - delphi中格式化字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15656793/