ISSUE #2010

    1% was changed from event to procedure

    This in a Note EWI. That means that the code has been upgraded but there are no pending actions that you need to take because the Visual Basic Upgrade Companion (VBUC) has already performed them for you and it this EWI is provided only to inform about this change.

    This EWI applies when you are migrating the HScrollBar or VScrollBar components from VB6.
    In VB6 the scroll event is triggered when we move the scroll button. However it does not execute when the user presses the up and down arrows.

    Vscrollbar screenshot

    Please notice that there are some differences between VB6 Scroll and .NET Scroll event. In VB6 the value property has been already updated when the event is fired. In .NET the Value property contains the previous value when the event fires. The updated values can be determined from the NewValue property of the ScrollEventArgs object.

    In summary the VBUC adjusted your scroll event changing it from an event handler to a procedure to handle the two differences:

    * That VB6 event is only when the scroll button is moved and not when the arrow keys are pressed
    * That VB6 NewValue is already updated by adding a new argument to the renamed scroll handler.

    In the snippets below you can see how the VBUC upgrades your code in this situation.

    Sample VB6

    Private Sub VScroll1_Scroll()
      MsgBox "Scroll"
    End Sub

    Target C#

    //UPGRADE_NOTE: (2020) VScroll1.Scroll was changed from an event to a procedure More Information: http://www.mobilize.net/vbtonet/ewis/ewi2020
    private void VScroll1_Scroll_Renamed(int newScrollValue)
    {
     
      MessageBox.Show("Scroll", AssemblyHelper.GetTitle(System.Reflection.Assembly.GetExecutingAssembly()));
    }

    private void VScroll1_Scroll(Object eventSender, ScrollEventArgs eventArgs)

      switch(
    eventArgs.Type)
      {
        case ScrollEventType.ThumbTrack:
          VScroll1_Scroll_Renamed(eventArgs.newValue);
        break; 
      }
    }

     


    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