Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

CheckBox Control for Visual Basic 6.0 Users

This topic compares the Visual Basic 6.0 CheckBox control with its equivalent in Visual Basic 2008.

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

Click Event

In Visual Basic 6.0, the Click event is raised when the CheckBox state is changed programmatically. In Visual Studio 2005 you use the CheckStateChanged event, not the Click event.

Additional Differences

In addition, there are numerous conceptual differences that apply to all controls, including differences in data binding, font handling, drag-and-drop, Help support, and more. For more information, see Windows Forms Overview and Additions to Windows Forms for the .NET Framework 2.0.

The following examples illustrate differences in coding techniques between Visual Basic 6.0 and Visual Basic 2008.

Code Changes for Responding to CheckBox Clicks

The following code demonstrates changing the text of a CheckBox control when a user checks or unchecks the control. The Visual Basic 6.0 Value property is replaced by the Visual Basic 2008 Checked property, and the Caption property is replaced by the Text property. Notice that the Visual Basic 2008 example uses the CheckStateChanged event to duplicate the behavior of the Visual Basic 6.0 Click event.

' Visual Basic 6.0
Private Sub Check1_Click()
    If Check1.Value = 1 Then
        Check1.Caption = "Checked"
    Else
        Check1.Caption = "Unchecked"
    End If
End Sub
' Visual Basic
Private Sub CheckBox1_CheckStateChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles CheckBox1.CheckStateChanged
    If CheckBox1.Checked = True Then
        CheckBox1.Text = "Checked"
    Else
        CheckBox1.Text = "Unchecked"
    End If
End Sub


Code Changes for Determining the State of a CheckBox

The following example demonstrates checking the state of a CheckBox control at run time.

' Visual Basic 6.0
Select Case Check1.Value
    Case vbUnchecked
        Check1.Caption = "Unchecked"
    Case vbChecked
        Check1.Caption = "Checked"
    Case vbGrayed
        Check1.Caption = "Disabled"
End Select
' Visual Basic
Select Case CheckBox1.CheckState
    Case CheckState.Unchecked
        CheckBox1.Text = "Unchecked"
    Case CheckState.Checked
        CheckBox1.Text = "Checked"
    Case CheckState.Indeterminate
        CheckBox1.Text = "Disabled"
End Select


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

Links are provided as necessary to topics explaining differences in behavior. Where there is no direct equivalent in Visual Basic 2008, links are provided to topics that present alternatives.

Properties

Visual Basic 6.0 Property

Visual Basic 2008 Equivalent

Alignment

0 (Left Justify)

1 (Right Justify)

CheckAlign

MiddleLeft enumeration value

MiddleRight enumeration value

Appearance

0 (Flat)

1 (3D)

FlatStyle enumeration

Flat enumeration value

Standard enumeration value

BackColor

BackColor

NoteNote:
For a list of color constants, see Color Handling for Visual Basic 6.0 Users.
NoteNote:
Colors are handled differently in Visual Basic 2008. For more information, see Color Behavior for Visual Basic 6.0 Users.

Caption

Text

Container

Parent

DataChanged

DataField

DataFormat

DataMember

DataSource

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

DisabledPicture

DownPicture

New implementation. For more information, see How to: Emulate a Visual Basic 6.0 Tri-State Control in an Upgraded Application.

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

NoteNote:
Fonts are handled differently in Visual Basic 2008. For more information, see Font Handling for Visual Basic 6.0 Users.

ForeColor

ForeColor

NoteNote:
For a list of color constants, see Color Handling for Visual Basic 6.0 Users.
NoteNote:
Colors are handled differently in Visual Basic 2008. For more information, see Color Behavior for Visual Basic 6.0 Users.

Height

Height, Size

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

HelpContextID

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

HWnd

Handle

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 2008. For more information, see Coordinate System for Visual Basic 6.0 Users.

MaskColor

New implementation. For more information, see MaskColor 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

Picture

Image

RightToLeft

True

False

RightToLeft

Yes enumeration value

No enumeration value

Style

0 (Standard)

1 (Graphical)

Appearance

Normal enumeration value

Button enumeration value

NoteNote:
There are differences in how the Graphical style is handled in Visual Basic 2008. For more information, see How to: Emulate a Visual Basic 6.0 Tri-State Control in an Upgraded Application.

Tag

Tag

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 2008. For more information, see Coordinate System for Visual Basic 6.0 Users.

UseMaskColor

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

Value

0 (vbUnchecked)

1 (vbChecked)

2 (vbGrayed)

CheckState

Unchecked enumeration value

Checked enumeration value

Indeterminate enumeration value

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 2008. For more information, see Coordinate System for Visual Basic 6.0 Users.

Methods

Visual Basic 6.0 Method

Visual Basic 2008 Equivalent

Drag

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

Move

SetBounds

NoteNote:
Coordinates are handled differently in Visual Basic 2008. 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.

SetFocus

Focus

ShowWhatsThis

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

ZOrder

0 (vbBringToFront)

1 (vbSendToBack)

BringToFront, SendToBack

Events

Visual Basic 6.0 Event

Visual Basic 2008 Equivalent

Click

CheckStateChanged

NoteNote:
In Visual Basic 6.0, the Click event is raised when the CheckBox state is changed programmatically. In Visual Basic 2008, the Click event is not raised; therefore, you should use the CheckStateChanged event.

DragDrop

DragOver

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

GotFocus

Enter

LostFocus

Leave

OLECompleteDrag

OLEDragDrop

OLEDragOver

OLEGiveFeedback

OLESetData

OLEStartDrag

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

Validate

Validating

When upgrading a Visual Basic 6.0 application using the Upgrade wizard, CheckBox controls are upgraded to Windows Forms CheckBox controls, and code is updated to use equivalent properties, methods, and events. Where there are no equivalents or where there are potential behavioral differences, comments are inserted into the code with a link to a Help topic.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft