Export (0) Print
Expand All

Color Changes in Visual Basic .NET

In Visual Basic 6.0, colors were represented by a value of type Long; in Visual Basic .NET colors are of type System.Drawing.Color. When a Visual Basic 6.0 application is upgraded, colors are converted using the System.Drawing.ColorTranslator.FromOle class.

In Visual Basic 6.0, constants were provided for the eight standard colors as well as for system colors that could be used to map a color to the user's system preferences. In Visual Basic .NET, the system colors are of type System.Drawing.SystemColors.

Color Constant Equivalents

System Color Constant Equivalents

Translating Colors

Color Constant Equivalents

Visual Basic 6.0Visual Basic .NET Equivalent
vbBlackSystem.Drawing.Color.Black
vbRedSystem.Drawing.Color.Red
vbGreenSystem.Drawing.Color.Lime
vbYellowSystem.Drawing.Color.Yellow
vbBlueSystem.Drawing.Color.Blue
vbMagentaSystem.Drawing.Color.Magenta
vbCyanSystem.Drawing.Color.Cyan
vbWhiteSystem.Drawing.Color.White

System Color Constant Equivalents

Visual Basic 6.0Visual Basic .NET Equivalent
vb3DDKShadowSystem.Drawing.SystemColors.ControlDarkDark
vb3DFaceSystem.Drawing.SystemColors.Control
vb3DHighlightSystem.Drawing.SystemColors.ControlLightLight
vb3DLightSystem.Drawing.SystemColors.ControlLight
vb3DShadowSystem.Drawing.SystemColors.ControlDark
vbActiveBorderSystem.Drawing.SystemColors.ActiveBorder
vbActiveTitleBarSystem.Drawing.SystemColors.ActiveCaption
vbActiveTitleBarTextSystem.Drawing.SystemColors.ActiveCaptionText
vbApplicationWorkspaceSystem.Drawing.SystemColors.AppWorkspace
vbButtonFaceSystem.Drawing.SystemColors.Control
vbButtonShadowSystem.Drawing.SystemColors.ControlDark
vbButtonTextSystem.Drawing.SystemColors.ControlText
vbDesktopSystem.Drawing.SystemColors.Desktop
vbGrayTextSystem.Drawing.SystemColors.GrayText
vbHighlightSystem.Drawing.SystemColors.Highlight
vbHighlightTextSystem.Drawing.SystemColors.HighlightText
vbInactiveBorderSystem.Drawing.SystemColors.InactiveBorder
vbInactiveCaptionTextSystem.Drawing.SystemColors.InactiveCaptionText
vbInactiveTitleBarSystem.Drawing.SystemColors.InactiveCaption
vbInactiveTitleBarTextSystem.Drawing.SystemColors.InactiveCaptionText
vbInfoBackgroundSystem.Drawing.SystemColors.Info
vbInfoTextSystem.Drawing.SystemColors.InfoText
vbMenuBarSystem.Drawing.SystemColors.Menu
vbMenuTextSystem.Drawing.SystemColors.MenuText
vbScrollBarsSystem.Drawing.SystemColors.Scrollbar
vbTitleBarTextSystem.Drawing.SystemColors.ActiveCaptionText
vbWindowBackgroundSystem.Drawing.SystemColors.Window
vbWindowFrameSystem.Drawing.SystemColors.WindowFrame
vbWindowTextSystem.Drawing.SystemColors.WindowText

Translating Colors

To find an equivalent value for a Visual Basic 6.0 color that is not covered by the color constants, you can use the System.Drawing.ColorTranslator class.

The following example sets the BackColor property of a TextBox control to match the lightest green (&H00C0FFC0) from the Visual Basic 6.0 color picker:

' Visual Basic .NET 
textBox1.BackColor = System.Drawing.ColorTranslator.FromOle(&H00C0FFC0)

See Also

Color Behavior Changes in Visual Basic .NET | Palette Changes in Visual Basic .NET | MaskColor Changes in Visual Basic .NET | Control Changes in Visual Basic .NET | UserControl Changes in Visual Basic .NET

Show:
© 2014 Microsoft