Inspection Details

ProcedureCanBeWrittenAsFunction


Summary
Warns about 'Sub' procedures that could be refactored into a 'Function'.
Reasoning
Idiomatic VB code uses 'Function' procedures to return a single value. If the procedure isn't side-effecting, consider writing is as a 'Function' rather than a 'Sub' the returns a result through a 'ByRef' parameter.
The following code example(s) would trigger this inspection:

Option Explicit
Public Sub DoSomething(ByRef result As Long)
    ' ...
    result = 42
End Sub

The following code example(s) would not trigger this inspection:

Option Explicit
Public Function DoSomething() As Long
    ' ...
    DoSomething = 42
End Function


Back to List