string VBscript 中是否有“\n”等价物?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2203710/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there "\n" equivalent in VBscript?
提问by Carlos Blanco
I want to use the Replace function in VBScript to replacea all line breaks in a string for "\n". I come from java, so using \n inside a string means a line break.
我想使用 VBScript 中的 Replace 函数将字符串中的所有换行符替换为“\n”。我来自 java,所以在字符串中使用 \n 表示换行。
Is there an equivalent in VBScript?
VBScript 中是否有等价物?
回答by Fionnuala
For replace you can use vbCrLf:
对于替换,您可以使用 vbCrLf:
Replace(string, vbCrLf, "")
You can also use chr(13)+chr(10)
您也可以使用 chr(13)+chr(10)
I seem to remember in some odd cases that chr(10) comes before chr(13)
我似乎记得在一些奇怪的情况下 chr(10) 出现在 chr(13) 之前
回答by T.J. Crowder
As David and Remou pointed out, vbCrLf
if you want a carriage-return-linefeed combination. Otherwise, Chr(13)
and Chr(10)
(although some VB-derivatives have vbCr
and vbLf
; VBScript may well have those, worth checking before using Chr
).
正如 David 和 Remou 指出的,vbCrLf
如果你想要一个回车换行组合。否则,Chr(13)
并且Chr(10)
(尽管一些 VB 派生词有vbCr
和vbLf
;VBScript 可能有这些,在使用前值得检查Chr
)。
回答by David
I thinks its vbcrlf.
我认为它的 vbcrlf。
replace(s,vbcrlf,"<br />"
回答by Rit Man
I had to use vbLf only in an ASP script where the original data was POSTed from a PHP script on a cPanel box over to ASP on a win server
我只能在 ASP 脚本中使用 vbLf,其中原始数据是从 cPanel 框上的 PHP 脚本发布到 win 服务器上的 ASP
(VBScript)
(VBScript)
EmailText = Replace(EmailText, vbLf, "<br>")
回答by iOSAndroidWindowsMobileAppsDev
Tried and tested. I know that this works:
尝试和测试。我知道这有效:
Replace(EmailText, vbNewLine, "<br>")
i.e. vbNewLine
is also the equivalent of \n
即vbNewLine
也相当于\n