Previous | Index | Next 

[INFO] Minor differences between VB6 and VB.NET UpDown controls

VB Migration Partner’s support library hides most of the differences between the VB6 and the .NET versions of the UpDown control, but not all of them. In most cases the remaining differences should have no impact on migrated programs. Here’s their complete list:

  1. Values assigned to the BuddyProperty at design-time aren’t converted and by default the .NET UpDown control consider the default property of the buddy control as the buddy property. For more information, read the KB article [PRB] The UpDown control can affect the wrong property of its buddy control.
  2. The AutoBuddy property isn’t supported and is marked as obsolete. This property always returns False; assigning it the True value throws an exception (if VB6Config.ThrowsOnUnsupportedMembers is True).
  3. In VB6 if you set the BuddyControl property to a non-Nothing value, the UpDown control automatically moves near its buddy control. If you later reset the BuddyControl property to Nothing or an empty string, the UpDown control moves back to its original location. The .NET UpDown control mimics the former behavior (it moves near to its buddy control) but doesn’t move back if the BuddyControl property is set to Nothing or empty string.
  4. In VB6, if the end user clicks on the arrows, the following sequence of events occurs: MouseDown, Change, MouseUp, DownClick (or UpClick). In .NET, the last two events are reversed and the sequence is: MouseDown. Change, DownClick (or UpClick), and MouseUp.
  5. While the VB6UpDown control behaves like the original VB6 control under normal circumstances, the equivalence isn’t always ensured under error conditions. In other words, it isn’t guaranteed that the VB6UpDown control raises an error with the same number as under VB6 and it isn’t guaranteed that, when an error occurs, property values are reset as they are in VB6.

Furthermore, In VB6 you can assign a control reference to the BuddyControl property with or without the Set keyword. In other words, both the following statements work correctly:

        Set UpDown1.BuddyControl = Text1
        UpDown1.BuddyControl = Text1

However, these statements are converted by VB Migration Partner as follows:

        UpDown1.BuddyControl = Text1      ' correct
        UpDown1.BuddyControl = Text1.Text ' wrong!

The simplest way to work around this problem is manually editing the VB6 code to add the Set keyword. If this isn’t practical – possibly, because there are too many occurrences of this syntax, you can use a PreProcess pragma, as in:

        '## PreProcess "(?<=\r\n\[ \t]*)\w+\.BuddyControl =", "Set $0", True


Previous | Index | Next