共用方式為


My.Computer.Clipboard.SetData Method 

Writes data in a custom format to the Clipboard.

' Usage
My.Computer.Clipboard.SetData(format ,data)
' Declaration
Public Sub SetData( _
   ByVal format As String, _
   ByVal data As Object _
)

Parameters

  • format
    String. Format of data. Required.
  • data
    Object. Data object to be written to the Clipboard. Required.

Exceptions

This method throws no exceptions.

Remarks

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.

Example

This example writes the DataObject dataChunk to the Clipboard in the custom format specialFormat.

My.Computer.Clipboard.SetData("specialFormat", dataChunk)

This example depends on the existence of the custom data format specialFormat.

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
My.Computer.Clipboard.ContainsData Method
My.Computer.Clipboard.GetData Method
My.Computer.Clipboard.GetDataObject Method
My.Computer.Clipboard.SetDataObject Method
SetData

Other Resources

Storing Data to and Reading From the Clipboard