VB Migration Partner


Previous | Index | Next 

[HOWTO] Convert VB6 files that are shared among projects

VB6 allows you to share a given source file – such as a BAS module or a class in a .cls file – among multiple projects, so that you can change one file and have your edits immediately propagated to all projects. Conversely, when you add an existing file to a .NET project, by default the file is physically copied to the project’s folder and all subsequent edits are not shared with other projects.

If you want to share a file among two or more .NET projects, you must use the Add Existing Item command (from Visual Studio’s Project menu), select the file, click on the down arrow to the right of the Add button, and click on the “Add as Link” command.

When using VB Migration Partner, by default all .vb files are created in the .NET project’s folder and aren’t shared with any other project. However, creating a “linked” file is just a matter of using a couple pragmas.

Let’s assume that you are migrating a VB6 project that contains a file named Functions.bas and that is shared by other projects.

The first time you convert a VB6 project that includes the Functions.bas file you don’t need to do anything special: just convert the project and ensure that it compiles correctly under .NET. If it doesn’t, add all the pragmas that are necessary to reach the zero-compilation error stage. At this point you have a Functions.vb file that works correctly.

Next, you copy the Functions.vb file to a different location, so that it isn’t overwritten if you migrate the same project again, for example to a folder named c:\SharedFiles.
You can now add two more pragmas to the Functions.bas file:

        '##  ExcludeCurrentFile
        '##  AddSourceFile c:\sharedfiles\functions.vb, True

VB Migration Partner will therefore convert the Function.bas file as usual, but the file will be discarded at the end of the migration step because of the ExcludeCurrentFile pragma, and will be replaced by the file referenced by the AddSourceFile pragma. By passing True as the second argument, VB Migration Partner adds the referenced file as if the “Open as Link” command were used.

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