0

I have this function, written from another post, except I am running into an issue where my messages need to be wordy so the end user doesn't panic, that being said, how do I break a sentence below so it will be readable while I am coding?

I hope this makes sense... thanks.

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
0

1 Answer 1

5

You can use the Underscore _ to break up lines of code like this:

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

Note

When breaking up strings you need to end the string with a "

Then add the ampersand & to concatenate before the underscore _like in the above example.

This tells VBA that the string is over, but will be joined to the string on the next line.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.