Inspection Details

ArgumentWithIncompatibleObjectType


Summary
Locates arguments passed to functions or procedures for object parameters which the do not have a compatible declared type.
Reasoning
The VBA compiler does not check whether different object types are compatible. Instead there is a runtime error whenever the types are incompatible.
The following code example(s) would trigger this inspection:

IInterface:
Public Sub DoSomething()
End Sub
------------------------------
Class1:
'No Implements IInterface
Public Sub DoSomething()
End Sub
------------------------------
Module1:
Public Sub DoIt()
    Dim cls As Class1
    Set cls = New Class1
    Foo cls
End Sub
Public Sub Foo(cls As IInterface)
End Sub

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

IInterface:
Public Sub DoSomething()
End Sub
------------------------------
Class1:
Implements IInterface
Private Sub IInterface_DoSomething()
End Sub
------------------------------
Module1:
Public Sub DoIt()
    Dim cls As Class1
    Set cls = New Class1
    Foo cls
End Sub
Public Sub Foo(cls As IInterface)
End Sub


Back to List