Udostępnij za pośrednictwem


My.Computer.Clipboard.GetText Method

Retrieves text from the Clipboard.

' Usage
Dim value As String = My.Computer.Clipboard.GetText()
Dim value As String = My.Computer.Clipboard.GetText(format)
' Declaration
Public Function GetText() As String
' -or-
Public Function GetText( _
   ByVal format As System.Windows.Forms.TextDataFormat _
) As String

Parameters

Return Value

String.

Exceptions

This method throws no exceptions.

Remarks

Possible formats are CommaSeparatedValue, Html, Rtf and UnicodeText.

The method requires AllClipboard.

This method returns an empty string if there is no data on the Clipboard that matches the specified format.

Tasks

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

To

See

Read text from the Clipboard

How to: Read from the Clipboard in Visual Basic

Example

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

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

This example fails if there is no text on the Clipboard.

Requirements

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

Permissions

No permissions are required.

See Also

Tasks

How to: Read from the Clipboard in Visual Basic

Reference

My.Computer.Clipboard Object

System.Windows.Forms.TextDataFormat

Clipboard.GetText

My.Computer.Clipboard.ContainsText Method

My.Computer.Clipboard.SetText Method