在Delphi 7中,如何在Format函数中避免百分号(%)? [英] In Delphi 7, how do I escape a percent sign (%) in the Format function?
本文介绍了在Delphi 7中,如何在Format函数中避免百分号(%)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想做这样的事情:
SQL.Text := Format('select foo from bar where baz like ''%s%''',[SearchTerm]);
但当然,格式不喜欢最后的'%'。那我该怎么逃避呢? \%
? %%
?
But Format doesn't like that last '%', of course. So how can I escape it? \%
? %%
?
或者我必须这样做:
SQL.Text := Format('select foo from bar where baz like ''%s''',[SearchTerm+'%']);
?
推荐答案
使用格式字符串中的另一个%:
Use another % in the format string:
SQL.Text := Format('select foo from bar where baz like ''%s%%''',[SearchTerm]);
这篇关于在Delphi 7中,如何在Format函数中避免百分号(%)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文