我有以下代码使用两个env变量显示MsgBox
:
Set wshShell = CreateObject("WScript.Shell")
Title = wshShell.ExpandEnvironmentStrings("%Title%")
Text = wshShell.ExpandEnvironmentStrings("%Text%")
x = MsgBox(Text, 4144, Title)
虽然代码有效,但我希望消息中没有换行符。我已阅读以下内容,讨论了这种情况: How to use \n new line in VB msgbox() ...?
但是,当我将env变量感知到以下变量时,它将按字面显示。
"This is the first line" & vbCrLf & "and this is the second line"
以防万一上面的代码不清楚...
使用以下批处理语句中的值设置环境变量%Title%
和%Text%
:
set Title="This is a title"
set Text="This is the first line" & vbCrLf & "and this is the second line"
代码读取并在消息框中显示这些环境变量。