VB Migration Partner

KNOWLEDGE BASE - General


Previous | Index | Next 

[HOWTO] Skipping one or more methods when applying the PreProcess or PostProcess pragmas

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

It is possible to apply the PreProcess or PostProcess pragmas to an entire file or project, except a well defined list of methods. There are two techniques to achieve this result.

In the first approach, you specify the name of all the methods to be skipped in the last argument of the PostProcess pragma. For example, let’s say that you want to change the variable “foo” into “foobar” anywhere in your project except the methods named FunctionOne, SubTwo, and PropertyThree you can use the following pragma:

         '##  PostProcess "\bfoo\b", "foobar", True, False, 
                 "(Sub|Function|Property)[  \t]+(?!(FunctionOne|SubTwo|PropertyThree)\b).+?
                 (End Sub|End Function|End  Property)"

In the second approach you can mark all the methods that you want to skip with a special comment (for example “SKIP”) and use the following pragma:

         '##  PreProcess "\bfoo\b", "foobar", True, False, 
                "\r\n(?![  \t]*'SKIP)[^\r]*\r\n[ \t]*(Private|Public|Friend)[  \t]*
                (?<kind>Sub|Function|Property)[ \t].+?(End[ \t]+\k<kind>)"

 

         'SKIP
         Private  Sub DoSomething()
             Dim foo As Integer
             foo = 25
         End  Sub

Notice that the latter approach works fine only with the PreProcess pragma; when applied to the PostProcess pragma it works well only if the source file doesn’t contain any Property procedure, because during the migration the position of these procedures (and therefore the remarks associated to them) are moved around in the generated .NET code.

Unfortunately, neither approach works well when converting to C#, because C# methods are closed by a generic curly brace rather than a more descriptive End Sub or End Function keyword.

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