How to insert a line break in a StringVar in Crystal Reports

强颜欢笑 提交于 2019-12-10 13:05:38

问题


How do I enter a line break (or other non-text characters usually solved with escape characters) in a StringVar in Crystal Reports?

Wanted output:

line 1
line 2

I've tried StringVar s := "line 1 \n line 2";, but that does not work.


回答1:


It may not be much of an improvement, but you could build a string-formatting, custom function:

// sf()
Function (Stringvar text)

    Stringvar Array keys := ["\n"];
    Stringvar Array values := [Chr(10)+Chr(13)];

    Numbervar i;

    For i := 1 to Ubound(keys) do (
        text := Replace(text, keys[i], values[i])
    );

    text;

//{@ text}
sf("line 1 \n line 2")

This would offer you some extensibility should you need to support additional escape sequences.




回答2:


i have simply used following code for line break

"This formula field " + ChrW(13) + " contains a line break!"




回答3:


I've found a functional, albeit not code aesthetical, solution:

StringVar s := "line 1" + chr(10) + chr(13) + "line 2";


来源:https://stackoverflow.com/questions/12177102/how-to-insert-a-line-break-in-a-stringvar-in-crystal-reports

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!