VB Migration Partner

KNOWLEDGE BASE - Language


Previous | Index | Next 

[HOWTO] Replace App6 properties with native VB.NET members

Note: this article only applies to conversions to VB.NET.

VB Migration Partner replaces the VB6 App object with the special App6 object, as in the following examples:

        lblCopyright.Version = App6.Major & "." & App6.Minor & App6.Revision

Most of the App6 members, however, are just wrappers around .NET Framework methods or properties of the My.Application.Info object, thus you might prefer to see the native .NET members in the generated code. VB Migration Partner doesn’t do the replacement automatically, but you can force it yourself with a bunch of PostProcess pragmas:

        '## PostProcess "\bApp6.EXEName\b", "My.Application.Info.AssemblyName"
        '## PostProcess "\bApp6.Path\b", "My.Application.Info.DirectoryPath"
        '## PostProcess "\bApp6.hInstance\b", "Process.GetCurrentProcess().ID"
        '## PostProcess "\bApp6.Comments\b", "My.Application.Info.Description"
        '## PostProcess "\bApp6.CompanyName\b", "My.Application.Info.CompanyName"
        '## PostProcess "\bApp6.FileDescription\b", "My.Application.Info.Title"
        '## PostProcess "\bApp6.LegalCopyright\b", "My.Application.Info.Copyright"
        '## PostProcess "\bApp6.LegalTrademarks\b", "My.Application.Info.Trademark"
        '## PostProcess "\bApp6.Major\b", "My.Application.Info.Version.Major"
        '## PostProcess "\bApp6.Minor\b", "My.Application.Info.Version.Minor"
        '## PostProcess "\bApp6.Revision\b", "My.Application.Info.Version.Build"
        '## PostProcess "\bApp6.ThreadID\b", "AppDomain.GetCurrentThreadID()"

Notice that the AppDomain.GetCurrentThreadID method is deprecated and marked as obsolete, therefore you’ll see an extra warning in the resulting VB.NET code.

App.Title property requires a more complex regular expression, because you can’t do the replacement when the property is written to:

        '## PostProcess  "(?<!\r\n[ \t]*)App6.Title(?!\s*=)",  "My.Application.Info.Title"

Message 8018 is emitted when the App.Title property is emitted; you may want to disable it:

        '## DisableMessage 8018

Finally, you can map the HelpFile, HelpContextID, and UnattendedApp properties to constants that are defined in the VisualBasic6_Support.bas module:

        '## PostProcess "\bApp6.HelpFile\b", "APP6_HELPFILE"
        '## PostProcess "\bApp6.HelpContextID\b", "APP6_HELPCONTEXTID"
        '## PostProcess "\bApp6.UnattendedApp\b", "APP6_UNATTENDEDAPP"

Remember to use the project: prefix for all these PostProcess pragmas, if you want them to apply to the entire project. Alternatively, store these pragmas in a VBMigrationPartner.pragmas file, so that you can easily apply it to all the projects you mean to convert.

Previous | Index | Next 




Follow Francesco Balena on VB6 migration’s group on

LinkedIn





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.

newsletter



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