0

我有这个功能,是从另一篇文章中写的,除了我遇到了一个问题,我的消息需要冗长,这样最终用户就不会惊慌,也就是说,我如何在下面打断一个句子,这样它才能在阅读时我在编码?

我希望这是有道理的......谢谢。

Function GetErrMsg(ErNo As Long) As String
    Select Case ErNo
        Case 91
            GetErrMsg = "This is a long message that needs to be broken into sections so it can be read normally in the programming box"
    End Select
End Function
4

1 回答 1

5

您可以使用下划线_来分解代码行,如下所示:

Function GetErrMsg(ErNo As Long) As String
    Select Case ErNo
        Case 91
           GetErrMsg = "This is a long message that needs to be broken into " & _ 
                "sections so it can be read normally in the programming box"
    End Select
End Function

笔记

拆分字符串时,您需要以"

然后像上面的例子一样在下划线之前添加与符号&连接。_

这告诉 VBA 字符串已经结束,但将在下一行连接到字符串。

于 2012-07-16T19:25:23.117 回答