Previous | Index | Next 

[PRB] Structures can’t have the same name as other members in VB.NET

Under VB6 it is legal to have a Type…End Type block with same name with a field, property, or method, as in this code:

        Public var As Variant

        Public Type var
            Name As String
        End Type

VB Migration Partner translates the above code as follows:

        Public var As Object

        Public Structure var
            Public Name As String
        End Structure

which causes a compilation error under VB.NET. The simplest way to solve this problem is to change the name of the structure in all the files or projects that reference it, from var to varSTRUCT (or any other unique name). This can be achieved by means of a PostProcess pragma:

 '## project:PostProcess "(?<=(\bAs\s+(New\s+)?|TypeOf\s+\S+\s+Is\s+|Class\s+|Structure\s+)
           ((\w+\.)*))var\b", "varSTRUCT"


Previous | Index | Next