WARNING #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.This varies from case to case. The following code illustrates this situation with the DragOver event. There several approaches depending of the particular event being migrated.

    Sample VB6

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

    Private Sub Text1_OLEDragOver(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single, State As Integer)
        'Make sure that the format is text.
        If Data.GetFormat(vbCFText) Then
            'If it is text, enable dropping for the second Textbox.
            Text1.OLEDropMode = vbOLEDropManual
        End If
    End Sub
    

    Target VB.NET

    'UPGRADE_WARNING: (2050) TextBox Event Text1.OLEDragOver was not upgraded.
    Private Sub Text1_OLEDragOver(ByVal Data As DataObject, ByVal Effect As Integer, ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single, ByVal State As Integer)
    	'Make sure that the format is text.
    	'UPGRADE_ISSUE: (2064) ClipBoardConstants property ClipBoardConstants.vbCFText was not upgraded.
    	If Data.GetFormat(UpgradeSolution1Support.UpgradeStubs.VBRUN_ClipBoardConstants.getvbCFText()) Then
    		'If it is text, enable dropping for the second Textbox.
    		'UPGRADE_ISSUE: (2070) Constant vbOLEDropManual was not upgraded.
    		'UPGRADE_ISSUE: (2064) TextBox property Text1.OLEDropMode was not upgraded.
    		Text1.setOLEDropMode(UpgradeSolution1Support.UpgradeStubs.VBRUN_OLEDropConstants.getvbOLEDropManual())
    	End If
    End Sub
    

    Manual changes for 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.

    Private Sub Text1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Text1.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
    	End If
    End Sub
    

    Target C#

    //UPGRADE_WARNING: (2050) TextBox Event Text1.OLEDragOver was not upgraded.
    private void Text1_OLEDragOver(DataObject Data, int Effect, int Button, int Shift, float X, float Y, int State)
    {
    	//Make sure that the format is text.
    	//UPGRADE_ISSUE: (2064) ClipBoardConstants property ClipBoardConstants.vbCFText was not upgraded.
    	if (Data.GetFormat((short) UpgradeStubs.VBRUN_ClipBoardConstants.getvbCFText()))
    	{
    		//If it is text, enable dropping for the second Textbox.
    		//UPGRADE_ISSUE: (2070) Constant vbOLEDropManual was not upgraded.
    		//UPGRADE_ISSUE: (2064) TextBox property Text1.OLEDropMode was not upgraded.
    		Text1.setOLEDropMode(UpgradeStubs.VBRUN_OLEDropConstants.getvbOLEDropManual());
    	}
    }
    

    Manual Changes for 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.

    private void Text1_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
        {
    		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