VB.NET doesn’t support byte-oriented string functions, such as LeftB, RightB, and MidB. VB Migration Partner converts these methods into calls to the special LeftB6, RightB6, and MidB6 methods, defined the support library. These replacement methods mimic their VB6 counterparts, but in most cases they fail to perfectly reproduce the original VB6 behavior. For this reason, the methods in the support library are marked as obsolete and generate both a migration message and a compiler warning.
To help users that work with non-Latin alphabets, starting with 1.11 version, the support library exposes the following helper methods that approximate the VB6 behavior a bit better: EncodeStr6, EncodeLeftB6, EncodeRightB6, EncodeMidB6 and EncodeInputB6
Dim s As String
s = EncodeLeftB6("abcde", 5)
The new methods solve one of the problems inherent to the standard XxxxB6 function by supporting an additional, optional Boolean parameter. If this parameter is passed True, then the method returns a Byte array rather than a string:
Dim bytes() As Byte
s = EncodeLeftB6("abcde", 5, True)
You can easily replace all the occurrences of standard XxxxB6 methods into the new EncodeXxxxB6 methods by means of a PostProcess pragma in the original VB6 code:
The pragmas are different if you are converting to C#:
If you have used the new EncodeXxxx methods in your VB6 code, you don’t need an explicit conversion from String to Byte array any longer, therefore you can drop occurrences of the StringToByteArray6 method and append True at the end of the argument list. The following pragma can do that automatically:
(Note that previous pragma fails if the EncodeXxxx6 method has one or more parameters that contain parenthesis.) Here’s the version needed when converting to C#
The new methods are defined also in the VisualBasic6_Support.bas module, therefore you can take a more granular decision about which byte-oriented methods are converted and use the new functionality.
Finally, a disclaimer is in order. Even with these improvements, the new methods can’t guaranteed that VB6 functionality is perfectly replicated; however they are an important step in the right direction.