Share via


My.Computer.Clipboard.ContainsText Method

Determines if there is text on the Clipboard.

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

Parameters

  • format
    TextDataFormat. If specified, identifies what text format to be checked for. Required.

Return Value

True if the Clipboard contains text; otherwise False.

Remarks

Possible formats are CommaSeparatedValue, Html, Rtf and UnicodeText.

The method requires AllClipboard.

Tasks

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

To

See

Determine whether the Clipboard contains text

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

Example

This example determines if HTML text is stored on the Clipboard and reads from the Clipboard if it does.

If My.Computer.Clipboard.ContainsText _
(System.Windows.Forms.TextDataFormat.Html) Then 
   Dim clipText As String = My.Computer.Clipboard.GetText()
End If

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

Reference

My.Computer.Clipboard Object

System.Windows.Forms.TextDataFormat

Clipboard.ContainsText

My.Computer.Clipboard.GetText Method

My.Computer.Clipboard.SetText Method

Other Resources

Storing Data to and Reading From the Clipboard