Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

My.Computer.Clipboard.SetText Method

Writes text to the Clipboard.

' Usage
My.Computer.Clipboard.SetText(text)
My.Computer.Clipboard.SetText(text ,format)
' Declaration
Public Sub SetText( _
   ByVal text As String _
)
' -or-
Public Sub SetText( _
   ByVal text As String, _
   ByVal format As System.Windows.Forms.TextDataFormat _
)
text

String. Text to be written. Required.

format

TextDataFormat. Format to be used when writing text. Default is UnicodeText. Required.

The following conditions may cause an exception:

Possible formats are CommaSeparatedValue, Html, Rtf and UnicodeText.

The method requires AllClipboard.

Previous Clipboard formats are not preserved.

Security noteSecurity Note:

Because the Clipboard can be accessed by other users, do not use it to store sensitive information, such as passwords or confidential data.

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

To

See

Write text to the Clipboard

How to: Write to the Clipboard in Visual Basic

This example writes the string This is a test string. to the Clipboard.

My.Computer.Clipboard.SetText("This is a test string.")

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

No permissions are required.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.