Upgrade Stubs using Extension Methods

The Stubs Generation feature creates stub declarations for those elements that could not be converted to .NET equivalents.

The VBUC uses Extension Methods for Stubs, so the code is more readable and maintainable

Stub declarations provide canned answers to calls made during execution, thus reducing compilation errors and allowing for easy implementation during the migration

In the following example, the Line method of the VB6 Form is not supported. The generated Upgrade Stub is easily implemented as shown below:

VB6 Code

Private Sub Form_Paint()
     Me.Line (0, 200)-(ScaleWidth, 400), vbRed
End Sub

.NET Code

private void  Form1_Paint( Object eventSender,  PaintEventArgs eventArgs)
{
      //UPGRADE_ISSUE: (2064) Form method Form1.Line was not upgraded. More Information: http://www.vbtonet.com/ewis/ewi2064.aspx
     this.Line(0, 200, (float)VB6.PixelsToTwipsX(ClientRectangle.Width), 200, ColorTranslator.ToOle(Color.Red), null);
}

public static void  Line(this  Form instance,  float X2,  float Y2,  float X1,  float Y1,  int Color,  object DrawModifier) {
     Artinsoft.VB6.Utils.NotUpgradedHelper.NotifyNotUpgradedElement("VB.Form.Line");
}

public static void  Line(this  Form instance,  float X2,  float Y2,  float X1,  float Y1,  int Color,  object DrawModifier){               
      Graphics g = instance.CreateGraphics();
      g.DrawLine(new Pen(ColorTranslator.FromOle(Color)), X1, (float)VB6.TwipsToPixelsY(Y1), X2, (float)VB6.TwipsToPixelsY(Y2));
}