Join GitHub today
Code Inspection: Invalid use of member #2189
When working with interfaces and base types, VBA can compile code that will fail at run-time.
Rubberduck should try to identify such problems at inspection-time.
Public Property Get FooBar() As String FooBar = "FooBar" End Property
Sub FizzBuzz() Dim bar As UserForm1 Set bar = UserForm1 Debug.Print bar.FooBar Dim foo As UserForm Set foo = UserForm1 'This compiles but fails at run-time Debug.Print foo.FooBar End Sub
Personally, I'm a bit surprised that the sample syntax for UserForm would cause runtime errors. That is not the same behavior with the Access form.
Dim MyForm As Access.Form
We have similar situation with
So I agree with @comintern that it should be picked up by the MemberNotOnInterface inspection, to warn the users to revise their declaration or to do explicit cast to the specific type. Note that explicit cast wouldn't even apply to the