2

情况就是这样,我有这个字符串表,在一个.res文件中,我有一些字符串加载到其中一个表单中,比如 Form1。在一个表单上,我想弹出一个消息框,其中包含使用从字符串表加载的消息LoadResString(1234)

当资源 ID 1234 包含"This is testing vbNewline This is a new line!."该字符串时,是否有可能使用上述函数将字符串加载到消息框(弹出框)上?我已经对其进行了测试:它还将打印出"vbNewline"命令并且不解析它。有没有其他方法可以解析生成这种消息的所述字符串?

这是测试
这是新行!

我希望出现这种信息。

4

2 回答 2

4

You are trying to put a VB constant in a String expression so it is treating it like text, you can try using the Replace Function ( I realize this is a .Net link but the signature is the same as the VB6 method) to remove your string and substitute the correct value something like this should work:

MsgBox (Replace(LoadResString(1234), "vbNewLine", vbNewLine))

or create a function like this:

Public Function ParseNewLine(value As String) As String
    ParseNewLine = Replace(value, "vbNewLine", vbNewLine)
End Function

and call it like this:

MsgBox (ParseNewLine(LoadResString(1234)))
于 2013-04-25T03:23:27.390 回答
2

为什么不将换行序列嵌入到 RES 文件中。如果您使用的是资源加载项,则可以按Ctrl+Enter插入这些字符。

在 Visual Studio 的资源编辑器和原始资源脚本中,您可以使用\n.

于 2013-04-25T14:48:49.127 回答