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 2008.

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 2008 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 2008 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 2008 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
My.Computer.Clipboard.Clear()
My.Computer.Clipboard.SetText("Hello")
If My.Computer.Clipboard.ContainsText Then
  TextBox1.Text = My.Computer.Clipboard.GetText
EndIf

Clipboard Constant Equivalencies

Visual Basic 6.0

Visual Basic 2008 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

Note

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

Tasks

How to: Clear the Clipboard in Visual Basic

How to: Read from the Clipboard in Visual Basic

How to: Determine What Type of File is Stored on the Clipboard in Visual Basic

How to: Save an Audio Stream to the Clipboard in Visual Basic

How to: Retrieve an Image from the Clipboard in Visual Basic

How to: Write to the Clipboard in Visual Basic

Reference

My.Computer.Clipboard Object

My.Computer.Clipboard Object Members