This documentation is archived and is not being maintained.

Clipboard Object for Visual Basic 6.0 Users 

The Clipboard object in Visual Basic 6.0 is replaced by a similar Clipboard object in Visual Basic 2005.

Conceptual Differences

In Visual Basic 6.0, the Clipboard object is used to store and retrieve text, images, and data to and from the system Clipboard.

Visual Basic 2005 has a Clipboard object in the My.Computer namespace with some new methods and some methods that are slightly different.

Clipboard Data Formats

In Visual Basic 6.0, constants are provided to define the type of data being passed to or retrieved from the Clipboard.

Visual Basic 2005 uses a DataFormats object to define the data type; several new data formats are supported. A list of Visual Basic 6.0 Clipboard format constants and their Visual Basic 2005 equivalents is provided later in this topic.

Code Changes for the Clipboard Object

The following example demonstrates storing and retrieving text using the Clipboard.

' Visual Basic 6.0 
Clipboard.Clear
Clipboard.SetText "Hello", vbCFText
If Clipboard.GetFormat(vbCFText) Then
   Text1.Text = Clipboard.GetText(vbCFText)
End If
' Visual Basic 2005
My.Computer.Clipboard.Clear()
My.Computer.Clipboard.SetText("Hello")
If My.Computer.Clipboard.ContainsText Then
  TextBox1.Text = My.Computer.Clipboard.GetText
End If

Clipboard Constant Equivalencies

Visual Basic 6.0 Visual Basic 2005 Equivalent

vbCFBitmap

Bitmap

vbCFDIB

Dib

vbCFEMetafile

EnhancedMetafile

vbCFFiles

FileDrop

vbCFLink

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

vbCFMetafile

MetafilePict

vbCFPalette

Palette

vbCFRTF

Rtf

vbCFText

Text

NoteNote

The DataFormats object is a part of the System.Windows.Forms namespace. In addition to the formats listed above, DataFormats supports several clipboard formats that were not supported in Visual Basic 6.0.

See Also

Show: