ISSUE #6002

    UserControl Event 1% is not supported.

    Description

    Using the VBUC, ActiveX controls can be migrated to .NETWindows Controls. This can present a problem when migrating certain ActiveX User Controls that implement Events that are no longer supported in .NET. In most cases, this is because they do not have an exact equivalent in .NET.

    Recommendations

    An understanding of both the source platform and the target platform is helpful in coming up with a viable solution. Some of this is described in MSDN's User Controls for Visual Basic 6.0 Users.

    Visual Basic 6.0 Support

    Resources for those unfamiliar with Visual Basic 6.0 ActiveX Controls:

    .Net Framework Support

    Sample VB6

    PrivateSub UserControl_WriteProperties(ByVal PropBag As PropertyBag)

    Debug.Print("WriteProperties")

    PropBag.WriteProperty("Caption", Caption, Extender.Name)

    EndSub

    Target VB.NET

    'UPGRADE_WARNING: (6003) VBRUN.PropertyBag object was not upgraded.

    'UPGRADE_WARNING: (6002) UserControl Event WriteProperties is not supported.

    PrivateSub UserControl_WriteProperties(ByRef PropBag As UpgradeStubs.VBRUN_PropertyBag)

    Debug.WriteLine("WriteProperties")

    'UPGRADE_ISSUE: (2064) UserControl property ShapeLabel.Extender was not upgraded.

    'UPGRADE_TODO: (1067) Member Name is not defined in type Object(...).

    'UPGRADE_ISSUE: (2069) PropertyBag method PropBag.WriteProperty was not upgraded.

    PropBag.WriteProperty("Caption", Caption, UpgradeStubs.VB_UserControl.getExtender(Me).Name)

    My.Settings.Caption = Me.Caption

    EndSub

    Expected VB.NET

    This solution makes use of Application Settings to replace Visual Basic 6's PropertyBag. In most cases this is not necessary as .NET's design model maintains the state of properties without the use of the Settings object. This example assumes that these values need to be preserved between instances of the program. We've also fixed up the code relating to use of the Extender object.

    PrivateSub UserControl_WriteProperties()

    Debug.WriteLine("WriteProperties")

    My.Settings.Caption = Me.Caption

    EndSub

    Target C#

    //UPGRADE_WARNING: (6003) VBRUN.PropertyBag object was not upgraded.

    //UPGRADE_WARNING: (6002) UserControl Event WriteProperties is not supported.

    privatevoid UserControl_WriteProperties(UpgradeStubs.VBRUN_PropertyBag PropBag)

    {

    Debug.WriteLine("WriteProperties");

    //UPGRADE_ISSUE: (2064) UserControl property ShapeLabel.Extender was not upgraded.

    //UPGRADE_TODO: (1067) Member Name is not defined in type object(...).

    //UPGRADE_ISSUE: (2069) PropertyBag method PropBag.WriteProperty was not upgraded.

    PropBag.WriteProperty("Caption", Caption, UpgradeStubs.VB_UserControl.getExtender(this).Name);

    Properties.Settings.Default.Caption = this.Name;

    }

    Expected C#

    This solution makes use of Application Settings to replace Visual Basic 6's PropertyBag. In most cases this is not necessary as .NET's design model maintains the state of properties without the use of the Settings object. This example assumes that these values need to be preserved between instances of the program.

    privatevoid UserControl_WriteProperties()

    {

    Debug.WriteLine("WriteProperties");

    Properties.Settings.Default.Caption = this.Name;

    }


    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