ISSUE #2050

    1% Event 2%.3% was not upgraded.

    Description

    The VBUC is able to map VB6 library members to .NET equivalents. These equivalents are chosen to provide maximum functional equivalence on the target platform. In particular scenarios, some class properties and events may not have a direct equivalent in .NET or may have not been mapped in the current release of the VBUC. The event handler is declared in the target source code but there are no equivalent events to associate the handler to.

    Recommendations

    • Use a more specialized/similar component to the original one, which provides the required events in the target platform.
    • Create an explicit invocation to the event handler method in the given circumstances to simulate the event triggering.
    • Associate the upgraded handler method to one or more .NET available events in case those events satisfy the code requirements and the original event behavior.
    • Refactor the code to apply a different solution. This strategy makes sense especially when the concepts in .NET are very different to the VB6 ones. In these cases it is likely that the way to implement a particular process should be done with a different approach.

    Sample VB6

    Sample taken from Drag & Drop Changes in Visual Basic .Net:

    PrivateSub Text2_OLEDragOver(ByVal Data As DataObject, ByVal Effect AsLong, ByVal Button AsInteger, ByVal Shift AsInteger, ByVal X AsSingle, ByVal Y AsSingle, ByVal State AsInteger)
       ' Make sure that the format is text.
       If Data.GetFormat(vbCFText) Then
          ' If it is text, enable dropping for the second TextBox.
          Text2.OLEDropMode = vbOLEDropManual
       EndIf
    EndSub

    Target VB.NET

    //UPGRADE_WARNING: (2050) TextBox Event Text2.OLEDragOver was not
    PrivateSub Text2_OLEDragOver(ByRef Data As DataObject, ByRef Effect AsInteger, ByRef Button AsInteger, ByRef Shift AsInteger, ByRef X AsSingle, ByRef Y AsSingle, ByRef State AsInteger)
       ' Make sure that the format is text.
       If Data.GetFormat(CShort(TextDataFormat.Text)) Then
          ' If it is text, enable dropping for the second TextBox.
          UpgradeStubs.VB_Control.setOLEDropMode(Text2, UpgradeStubs.VBRUN_OLEDropConstants.getvbOLEDropManual())
       EndIf
    EndSub

    Expected VB.NET

    In this case the sample code deals with manually handling Drag & Drop operations in a Visual Basic 6 application. As stated previously the sample code is from Drag & Drop Changes in Visual Basic .Net.

    As is clearly stated in that MSDN article we need to write custom code for the drag & drop operation. In this case we replace the OLEDragOver event which no longer exists in .Net and replace it with the DragEnter event. Within this event we add our drag & drop logic.

    PrivateSub Text2_DragEnter(ByVal sender AsObject, ByVal e As System.Windows.Forms.DragEventArgs) Handles TextBox2.DragEnter
       ' Make sure that the format is text.
       If (e.Data.GetDataPresent(DataFormats.Text)) Then
          ' Allow drop.
          e.Effect = DragDropEffects.Copy
       Else
          ' Do not allow drop.
          e.Effect = DragDropEffects.None
       EndIf
    EndSub

    Target C#

    //UPGRADE_WARNING: (2050) TextBox Event Text2.OLEDragOver was not upgraded.
    privatevoid Text2_OLEDragOver( DataObject Data, int Effect, int Button, int Shift, float X, float Y, int State)
    {
       // Make sure that the format is text.
       if (Data.GetFormat((short) TextDataFormat.Text))
       {
        // If it is text, enable dropping for the second TextBox.
        //UPGRADE_ISSUE: (2070) Constant vbOLEDropManual was not upgraded.
        //UPGRADE_ISSUE: (2064) TextBox property Text2.OLEDropMode was not upgraded.
        UpgradeStubs.VB_Control.setOLEDropMode(Text2, UpgradeStubs.VBRUN_OLEDropConstants.getvbOLEDropManual());
       }
    }

    Expected C#

    In this case the sample code deals with manually handling Drag & Drop operations in a Visual Basic 6 application. As stated previously the sample code is from Drag & Drop Changes in Visual Basic .Net.

    As is clearly stated in that MSDN article we need to write custom code for the drag & drop operation. In this case we replace the OLEDragOver event which no longer exists in .Net and replace it with the DragEnter event. Within this event we add our drag & drop logic.

    privatevoid Text2_DragEnter(object sender, DragEventArgs e)
    {
        //Make sure that the format is text.
        if(e.Data.GetDataPresent(DataFormats.Text))
       {
         // Allow drop.
         e.Effect = DragDropEffects.Copy;
       } else {
          // Do not allow drop.
          e.Effect = DragDropEffects.None;
       }
    }


    Download VBUC Free Trial
    Download VBUC Now

    It's time to eradicate VB6
    ROI of eradicating VB6

    8 Proven Tips for
    Planning a Successful Migration

    8 Tips for migration