Reputation: 1044
Just as an example, say I'd like to reference a msgbox in multiple areas, could I create a function for this? Private or Public? Differences?
Here's an example.
Public Function Message() As String
MsgBox("Test Message")
End Function
Also, why would I get the following message: Function 'Message' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used
It seems as though its just a warning and it seemed to work when I called the function.
Upvotes: 0
Views: 46
Reputation: 17808
Make it Sub
so it's not expecting a return value.
Public Sub Message() As String
MsgBox("Test Message")
End Sub
Upvotes: 1