delphi - delphi中格式化字符串

标签 delphi

我想要更新“更新报告 (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/

相关文章:

delphi - Delphi 7 IDE-列表读取访问中的索引超出范围

ruby-on-rails - 在 Mac OS X 上的 Ruby on Rails 中使用 Delphi

delphi - Delphi XE2 中的 TDataModule.ClassGroup 伪属性到底有什么作用?

delphi - 如何从TActionManager获取所有TAction?

delphi - 平移时如何获取 TScrollBox 在 TLayout 中的位置?

delphi - 阻塞套接字会触发哪些事件?

delphi - 快速报告显示来自 ADOQuery 的不正确数据

delphi - 在 C++ Builder 中连接和使用 Delphi DLL

C 到 Delphi 翻译

delphi - TWebBrowser 在浏览阻塞 html 期间挂起主线程