Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Visual Basic

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Visual Basic Language Reference
My.Computer.Clipboard Object

Provides methods for manipulating the Clipboard.

Items moved or copied to the Clipboard persist even after the application is shut down.

Data on the Clipboard can be in any data format, also called a Clipboard format. For a list of predefined formats to use with the Clipboard, see DataFormats. When an item is moved or copied to the Clipboard, items in other formats are cleared. To make other formats persist, use DataObject, which copies everything existing on the current Clipboard, including items pasted from other applications. Place data on the Clipboard in multiple formats to maximize the possibility that a target application, whose format requirements you might not know, can successfully retrieve the data.

Because all Windows applications share the system Clipboard, the contents may change when you switch to another application.

A class must be serializable for it to be put on the Clipboard. When accessing the Clipboard remotely, a ThreadStateException is thrown unless the accessing thread operates in STA (single-threaded apartment) mode. To resolve this issue, set the ThreadApartmentState to STA. For more information, see STAThreadAttribute.

The following table lists examples of tasks involving the My.Computer.Clipboard object.

This example reads text from the Clipboard into the string textOnClipboard.

Visual Basic
Dim textOnClipboard As String = My.Computer.Clipboard.GetText()

This example will fail if there is no text on the Clipboard.

Namespace: Microsoft.VisualBasic.MyServices

Class: ClipboardProxy (provides access to Clipboard)

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

Availability by Project Type

Project type

Available

Windows Application

Yes

Class Library

Yes

Console Application

Yes

Windows Control Library

Yes

Web Control Library

No

Windows Service

Yes

Web Site

No

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker