VB Migration Partner


Previous | Index | Next 

[PRB] The migrated VB.NET application can’t compile because of the error “ ‘XYZ’ is already declared in this enum”

VB6 is more forgiving than VB.NET in how names can be assigned to items in an Enum block. For example, the following code is valid under VB6:

        Public Enum TestEnum
            [Sub]      ' names can be equal to reserved keywords
            [16 bit]   ' names can contain spaces
            [2D]       ' names can start with a digit
            [Three-D]  ' names can contain invalid characters
        End Enum

VB.NET accepts enum items whose name matches a language keyword (if the name is enclosed between square brackets), but rejects with a compilation error any attempt to use spaces or other invalid characters, as well as names that start with a digit. 

VB Migration Partner follows the following strategy when converting enum items: it renders spaces and invalid characters as underscores and prefixes the name with another underscore if the name starts with a digit. As in VB6, if the name matches a language keyword, the name is enclosed between square brackets. 

This conversion strategy works in nearly all cases, but you should be aware that there is a small chance that it generates two or more enum elements with same name. For example, the following VB6 Enum block:

        Public Enum TestEnum
        End Enum

produces three Enum elements with same name, which in turn produces two instances of the following error message:

        '_16bit_' is already declared in this enum

The obvious fix for this problem is renaming one or more enum items in the original VB6 code so that no duplicate names are created during the migration process.

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