- 
                Notifications
    
You must be signed in to change notification settings  - Fork 316
 
NonReturningFunctionInspection
Description: Function does not return anything
Type: CodeInspectionType.CodeQualityIssues
Default severity: CodeInspectionSeverity.Warning
This inspection finds function procedures that don't assign their return value.
Function DoSomething below seems to return an Integer, but because it is never assigned, it will always return 0:
Public Function DoSomething() As Integer
    Dim foo As Integer
    foo = 42
    DoSomethingElse foo
End Sub
This code is confusing, because a maintainer would expect DoSomething to return an Integer. Either the function is accidentally unassigned, or the function should be a Sub.
QuickFix: Convert function to procedure
Public Sub DoSomething()
    Dim foo As Integer
    foo = 42
    DoSomethingElse foo
End Sub
By making the unassigned function a Sub procedure, there is no more ambiguity on whether the function was accidentally unassigned, or if it was meant to be a Sub.
IMPORTANT Functions consumed by Microsoft Access macros must be Function procedures; when a VBA function is used by a Microsoft Access macro, applying this quickfix can break macros. Assign the function an error code instead (like DoSomething = 0) - Rubberduck will no longer mark the function as non-returning, and functionality will be preserved.
 rubberduckvba.com
© 2014-2025 Rubberduck project contributors
- Contributing
 - Build process
 - Version bump
 - Architecture Overview
 - IoC Container
 - Parser State
 - The Parsing Process
 - How to view parse tree
 - UI Design Guidelines
 - Strategies for managing COM object lifetime and release
 - COM Registration
 - Internal Codebase Analysis
 - Projects & Workflow
 - Adding other Host Applications
 - Inspections XML-Doc
 
- 
VBE Events