The Microsoft.VisualBasic.Compatibility.dll assembly (part of the .NET Framework) contains many classes that are used by the Upgrade Wizard conversion tool included in Visual Studio. Among these classes you can find the "controlarray" equivalent for each control and many other classes to support special VB6 features (e.g. WebClasses).

In most cases you can forget about the DLL, if you migrate your code using our VB Migration Partner software. For example, VB Migration Partner doesn't use a different controlarray class for each different control. Instead, it leverages generics and has just one class - namely VB6ControlArray(Of T) - that works as a control array for each possible control. The clear benefit is that VB Migration Partner seeminglessly support arrays of *any* control, including custom UserControls and ActiveX controls. (Sorry, Upgrade Wizard...)




However, the Microsoft.VisualBasic.Compatibility assembly contains at least one class that deserves your attention: the Support module. This module exposes several helper methods that can solve many conversion issues. For example, the following methods are real lifesavers when converting between OLE types and .NET types:

Function CursorToIPicture(cur As cursor) As Object
Returns an OLE IPicture object that corresponds to the specified System.Windows.Forms.Cursor.

Function FontToIFont(font As Font) As Object
Converts a System.Drawing.Font to a Visual Basic 6.0 stdFont object.

Function IconToIPicture(ico As Icon) As Object
Gets an OLE IPicture object for a given System.Drawing.Icon.

Function IFontToFont(objFnt As Object) As Font
Converts a Visual Basic 6.0 stdFont object to a System.Drawing.Font.

Function ImageToIPicture(img As Image) As Object
Gets an OLE IPicture object for a given System.Drawing.Image.

Function ImageToIPictureDisp(img As Image) As Object
Gets an OLE IPictureDisp object for a given System.Drawing.Image.

Function IPictureDispToImage(pict As Object) As Image
Gets a System.Drawing.Image for a given OLE IPictureDisp object.

Function IPictureToImage(pict As Object) As Image
Gets a System.Drawing.Image for a given OLE IPicture object.

Another group of methods can greatly simplify coordinate conversions:

Function FromPixelsUserHeight(Height As Double, ScaleHeight As Double, OriginalHeightInPixels As Integer) As Double
Converts a pixel measurement to a Visual Basic 6.0 ScaleHeight measurement.

Function FromPixelsUserWidth(Width As Double, ScaleWidth As Double, OriginalWidthInPixels As Integer) As Double
Converts a pixel measurement to a Visual Basic 6.0 ScaleWidth measurement.

Function FromPixelsUserX(X As Double, ScaleLeft As Double, ScaleWidth As Double, OriginalWidthInPixels As Integer) As Double
Converts a pixel measurement to a Visual Basic 6.0 ScaleLeft measurement.

Function FromPixelsUserY(Y As Double, ScaleTop As Double, ScaleHeight As Double, OriginalHeightInPixels As Integer) As Double
Converts a pixel measurement to a Visual Basic 6.0 ScaleTop measurement.

Function FromPixelsX(X As Double, ToScale As ScaleMode) As Double
Converts a pixel measurement to a Visual Basic 6.0 measurement for a given Microsoft.VisualBasic.Compatibility.VB6.ScaleMode.

Function FromPixelsY(Y As Double, ToScale As ScaleMode) As Double
Converts a pixel measurement to a Visual Basic 6.0 measurement for a given Microsoft.VisualBasic.Compatibility.VB6.ScaleMode.

Function PixelsToTwipsX(X As Double) As Double
Converts an X coordinate from pixels to twips.

Function PixelsToTwipsY(Y As Double) As Double
Converts a Y coordinate from pixels to twips.

Function ToPixelsUserHeight(Height As Double, ScaleHeight As Double, OriginalHeightInPixels As Integer) As Double
Converts a Visual Basic 6.0 ScaleHeight measurement to a pixel measurement.

Function ToPixelsUserWidth(Width As Double, ScaleWidth As Double, OriginalWidthInPixels As Integer) As Double
Converts a Visual Basic 6.0 ScaleWidth measurement to a pixel measurement.

Function ToPixelsUserX(X As Double, ScaleLeft As Double, ScaleWidth As Double, OriginalWidthInPixels As Integer) As Double
Converts a Visual Basic 6.0 ScaleLeft measurement to a pixel measurement.

Function ToPixelsUserY(Y As Double, ScaleTop As Double, ScaleHeight As Double, OriginalHeightInPixels As Integer) As Double
Converts a Visual Basic 6.0 ScaleTop measurement to a pixel measurement.

Function ToPixelsX(X As Double, FromScale As ScaleMode) As Double
Converts a Visual Basic 6.0 measurement to a pixel measurement for a given Microsoft.VisualBasic.Compatibility.VB6.ScaleMode.

Function ToPixelsY(Y As Double, FromScale As ScaleMode) As Double
Converts a Visual Basic 6.0 measurement to a pixel measurement for a given Microsoft.VisualBasic.Compatibility.VB6.ScaleMode.

Function TwipsPerPixelX() As Single
Gets a value that is used to convert twips to pixels based on screen settings.

Function TwipsPerPixelY() As Single
Gets a value that is used to convert twips to pixels based on screen settings.

Function TwipsToPixelsX(X As Double) As Double
Converts an X coordinate from twips to pixels.

Function TwipsToPixelsY(Y As Double) As Double
Converts a Y coordinate from twips to pixels.

Finally, there are a few useful methods that don't fall in a specific category:

Function GetActiveControl() As Control
Gets the control that currently has focus.

Function GetEXEName() As String
Gets the name of the executable file (.exe) for the current application.

Function GetHInstance() As System.IntPtr
Gets the instance handle (HINSTANCE) for the current application.

Function GetPath() As String
Gets the current path for the application.

Function TabLayout(ParamArray Args() As Object) As String
Formats strings to simulate the Visual Basic 6.0 Debug.Print functionality.

Sub WhatsThisMode(ByVal Form As Form)
Displays pop-up Help for a form upgraded from Visual Basic 6.0.

Sub ZOrder(Control As Control, Position As Integer)
Converts the Visual Basic ZOrder method for use in Visual Basic .NET.