Skip to content

ImplicitByRefParameterInspection

Mathieu Guindon edited this page Feb 23, 2015 · 2 revisions

Description: Parameter is passed ByRef implicitly

Type: CodeInspectionType.CodeQualityIssues

Default severity: CodeInspectionSeverity.Warning

This inspection finds procedure parameters that are implicitly passed by reference.

###Example:

Parameter foo is implicitly passed ByRef in this method signature:

Public Sub DoSomething(foo As Integer)
End Sub

This code is potentially confusing, because it assumes the maintainer knows VBA passes parameter ByRef by default. Other languages, including VB.NET, pass parameters by value by default.


###QuickFixes

QuickFix: Pass parameter by reference explicitly

Public Sub DoSomething(ByRef foo As Integer)
End Sub

By explicitly specifying a parameter is passed by reference, there is no possible ambiguity and the maintainer knows how the parameter is passed, regardless of their knowledge of VBA.