VB Migration Partner


Previous | Index | Next 

[PRB] Compilation errors with classes or usercontrols that expose events with same name as other members and that are used to define an interface

In VB6 it is legal to define a class that exposes an event with same name as a property or method, as in the following case:

        ' inside the Widget class
        Public Event FormatText()

        Public Sub FormatText()
            ' …
        End Sub

VB Migration Partner handles this case quite nicely and automatically generates a different name for the property or the method:

        Public Class Widget
Public Event FormatText() Public Sub FormatText_RENAMED() ' … End Sub End Class

However, a problem arises if the class appears in an Implements clause elsewhere in the project and therefore must be rendered as an interface. (This problem also arises if the class is marked with a ClassRenderMode pragma with Interface or ClassAndInterface argument.). In this case VB Migration Partner generates an incorrect Implements statement for the method, as in the following example:

        Public Class WidgetClass
            Implements Widget    ' error #1

            Public Event FormatText()
            Public Sub FormatText_RENAMED() Implements Widget.FormatText    ' error #2
                ' …
            End Sub
        End Class
        Public Interface Widget
            Sub FormatText()
        End Interface

The two statements marked with a comment cause the following compilation errors:

        Class 'Widget' must implement 'Sub FormatText_RENAMED()' for interface 'Widget'

        'FormatText_RENAMED' cannot implement 'FormatText' because there is no matching 
        sub on interface 'Widget'

The same two compilation errors also appear in any other class that contains an “Implements Widget” statement.

There is a simple workaround for this issue: just insert the following project-level PostProcess pragma somewhere in the Widget class:

        '## project:PostProcess "Widget\.FormatText", "$0_RENAMED"
Previous | Index | Next 

Follow Francesco Balena on VB6 migration’s group on


Read Microsoft Corp’s official case study of a VB6 conversion using VB Migration Partner.

Code Architects and its partners offers remote and onsite migration services.

More details

Subscribe to our free newsletter for useful VB6 migration tips and techniques.


To learn more about your VB6 applications, run VB6 Analyzer on your source code and send us the generated text file. You will receive a detailed report about your VB6 applications and how VB Migration Partner can help you to quickly and effectively migrate it to .NET.

Get free advice

A fully-working, time-limited Trial Edition of VB Migration Partner allows you to test it against your actual code

Get the Trial

The price of VB Migration Partner depends on the size of the VB6 application, the type of license, and other factors

Request a quote

Migrating a VB6 application in 10 easy steps

Comparing VB Migration Partner with Upgrade Wizard

Migration tools: Feature Comparison Table

All whitepapers