Export (0) Print
Expand All
Expand Minimize

Label Control for Visual Basic 6.0 Users 

This topic compares the Visual Basic 6.0 Label control with its equivalent in Visual Basic 2005.

The Label control in Visual Basic 6.0 is replaced by the Windows Forms Label control in Visual Basic 2005. The names of some properties, methods, events, and constants are different, and in some cases there are behavior differences.

Conceptual Differences

BackStyle Property

In Visual Basic 6.0, the BackStyle property of the Label control determines whether the label had a transparent background. Setting the BackStyle property to 0 – Transparent allows any background image to show through the label. If the label is placed over other controls, the controls also show through.

In Visual Basic 2005, the BackStyle property no longer exists and the transparency behavior is slightly different. To emulate the transparent behavior in Visual Basic 2005, set the BackColor property to Transparent. This will allow the background image to show through. If the label is placed over other controls, the controls will show through only if they are higher in the z-order.

NoteNote

The ZOrder method no longer exists in Visual Basic 2005. At design time you can use the Bring to Front or Send to Back command on the Format menu; at run time you can use the BringToFront or SendToBack function.

WordWrap Property

In Visual Basic 6.0, the WordWrap property determines if text wraps to multiple lines when it is too long to fit in a label.

In Visual Basic 2005, the text in a Label control automatically wraps. The only way to prevent wrapping is to make the height of the Label control equivalent to a single line of text.

Other Differences

In addition, there are numerous conceptual differences that apply to all controls, including differences in data binding, font handling, drag-and-drop functionality, Help support and more. For more information, see Windows Forms Concepts for Visual Basic 6.0 Users.

Code Changes for the Label Control

The following code example illustrates the differences in coding techniques between Visual Basic 6.0 and Visual Basic 2005.

Code Changes for Making a Label Transparent

The following example demonstrates making the background of a label control transparent. In Visual Basic 6.0, if there are other controls behind the Label, those controls show through. In the Visual Basic 2005 example, any controls behind the Label can optionally show through using the BringToFront and SendToBack functions.

' Visual Basic 6.0 
Private Sub MakeTransparent()
    Label1.BackStyle = vbTransparent
End Sub
' Visual Basic 2005
Private Sub MakeTransparent()
  Label1.BackColor = System.Drawing.Color.Transparent
  ' Let controls behind the label show through.
  Label1.SendToBack()
  ' Make the portion of controls behind the label transparent
  Label1.BringToFront()
End Sub

Label Control Property, Method, and Event Equivalencies

The following tables list Visual Basic 6.0 properties, methods, and events, along with their Visual Basic 2005 equivalents. Those properties, methods, and events that have the same name and behavior are not listed. Where applicable, constants are indented beneath the property or method. All Visual Basic 2005 enumerations map to the System.Windows.Forms namespace unless otherwise noted.

This table provides necessary links to topics explaining behavior differences. Where there is no direct equivalent in Visual Basic 2005, links are provided to alternatives.

Label Properties

Visual Basic 6.0 Visual Basic 2005 Equivalent

Alignment:

0 - Left Justify

1 - Right Justify

TextAlign

MiddleLeft enumeration value

MiddleRight enumeration value

Appearance

New implementation. For more information, see Appearance and BorderStyle Properties for Visual Basic 6.0 Users.

AutoSize

AutoSize

BackColor

BackColor

Note   For a list of constants, see Color Handling for Visual Basic 6.0 Users.

NoteNote

Colors are handled differently in Visual Basic 2005. For more information, see Color Behavior for Visual Basic 6.0 Users.

BackStyle

New implementation. For more information, see Conceptual Differences above.

Caption

Text

Container

Parent

DataChanged

DataField

DataFormat

DataMember

DataSource

New implementation. For more information, see Data Access for Visual Basic 6.0 Users.

DragIcon

DragMode

New implementation. For more information, see Drag and Drop for Visual Basic 6.0 Users.

Font

FontBold

FontItalic

FontName

FontSize

FontStrikethrough

FontUnderline

Font

Note   Fonts are handled differently in Visual Basic 2005. For more information, see Font Handling for Visual Basic 6.0 Users.

ForeColor

ForeColor

NoteNote

For a list of constants, see Color Handling for Visual Basic 6.0 Users.

NoteNote

Colors are handled differently in Visual Basic 2005. For more information, see Color Behavior for Visual Basic 6.0 Users.

Height

Height, Size

NoteNote

Coordinates are handled differently in Visual Basic 2005. For more information, see Coordinate System for Visual Basic 6.0 Users.

Index

New implementation. For more information, see Control Arrays for Visual Basic 6.0 Users.

Left

Left

NoteNote

Coordinates are handled differently in Visual Basic 2005. For more information, see Coordinate System for Visual Basic 6.0 Users.

LinkItem

LinkMode

LinkTimeOut

LinkTopic

No equivalent. For more information, see Dynamic Data Exchange for Visual Basic 6.0 Users.

MouseIcon

New implementation. For more information, see Cannot set a custom MousePointer.

MousePointer

Cursor

For a list of constants, see MousePointer for Visual Basic 6.0 Users.

OLEDropMode

New implementation. For more information, see Drag and Drop for Visual Basic 6.0 Users.

Parent

FindForm method

RightToLeft:

 True

 False

RightToLeft

 Yes enumeration value

 No enumeration value

ToolTipText

ToolTip component

For more information, see ToolTip Support for Visual Basic 6.0 Users.

Top

Top

NoteNote

Coordinates are handled differently in Visual Basic 2005. For more information, see Coordinate System for Visual Basic 6.0 Users.

WhatsThisHelpID

New implementation. For more information, see Help Support for Visual Basic 6.0 Users.

Width

Width, Size

NoteNote

Coordinates are handled differently in Visual Basic 2005. For more information, see Coordinate System for Visual Basic 6.0 Users.

WordWrap

New implementation.

NoteNote

Text in the Visual Basic 2005 Label control wraps by default and cannot be changed.

Label Methods

Visual Basic 6.0 Visual Basic 2005 Equivalent

Drag

New implementation. For more information, see Drag and Drop for Visual Basic 6.0 Users.

LinkExecute

LinkPoke

LinkRequest

LinkSend

No equivalent. For more information, see Dynamic Data Exchange for Visual Basic 6.0 Users.

Move

SetBounds

NoteNote

Coordinates are handled differently in Visual Basic 2005. For more information, see Coordinate System for Visual Basic 6.0 Users.

OLEDrag

New implementation. For more information, see Drag and Drop for Visual Basic 6.0 Users.

ShowWhatsThis

New implementation. For more information, see Help Support for Visual Basic 6.0 Users.

ZOrder:

 0 – vbBringToFront

 1 - vbSendToBack

BringToFront or SendToBack method

 BringToFront

 SendToBack

Label Events

Visual Basic 6.0 Visual Basic 2005 Equivalent

Change

TextChanged

DblClick

DoubleClick

DragDrop

DragOver

New implementation. For more information, see Drag and Drop for Visual Basic 6.0 Users.

LinkClose

LinkError

LinkNotify

LinkOpen

No equivalent. For more information, see Dynamic Data Exchange for Visual Basic 6.0 Users.

OLECompleteDrag

OLEDragDrop

OLEDragOver

OLEGiveFeedback

OLESetData

OLEStartDrag

New implementation. For more information, see Drag and Drop for Visual Basic 6.0 Users.

Upgrade Notes

When a Visual Basic 6.0 application is upgraded to Visual Basic 2005, any Label controls are upgraded to Windows Forms Label controls, and properties, methods and events are upgraded to their equivalent. Where there may be differences in behavior, upgrade comments are inserted into the code.

See Also

Community Additions

ADD
Show:
© 2014 Microsoft