- INDEX VB TO NET
- VBUC FEATURES
- ERROR HANDLING TRANSFORMATION FEATURES
- UNSTRUCTURED TO STRUCTURED FLOW CONTROL
Unstructured to Structured Flow Control
The VBUC includes features to remove unstructured “spaghetti” code and replace it with structured flow control statements in .NET. Unused labels are removed from the target .NET code. Some of the main patterns are described in this section.
GoTo Removal
Goto to Do-While Statements
Some Goto statements are used to loop a code block. The VBUC recognizes and converts those cases that can be transformed into a structured iteration block, as shown in the following example:
[VB6]
myLabel: stmt-1 ... <optional break statement> ... stmt-n Goto myLabel
[C#]
do { stmt1; ... <optional break statement> ... stm2; } while (true);
Goto to If Statement
Several combinations of If statements containing Gotos are supported by improving the If pattern. The code blocks involved are included into the true/false blocks of the original If.
A very simple example is as follows:
[VB6]
If Cond Then Goto myLabel <CodeBlock1> myLabel: <CodeBlock2>
[C#]
If Not Cond Then <CodeBlock1> End If <CodeBlock2>