Not being entirely sure how to best articulate the title, I'll try to explain myself better here..
I do a lot of cutting and pasting of templated chunks of code that I repeat in most of my functions - typically, error handling and debugging facilities in general.
As returning values from functions is done by declaring MyFunction = "SomeValue"
, I figure there is little harm in asking if there is any way of generalizing away "MyFunction" (in this example)?
E.g.:
Function MyFunction() As String
On Error GoTo ErrHandler
' <..do stuff here..>
Exit Function
ErrHandler:
MyFunction = "Something bad happened"
End Function
So if I were to copy this chunk as a template for all my future functions, I would love not having to replace every occurrence of the word MyFunction
in the code.. So I wonder if there is some arbitrary keyword like Me
to return the function's resultant value like you would use the Return function in C.
Hope that made sense!