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 _
)
Parameters
text
String. Text to be written. Required.format
TextDataFormat. Format to be used when writing text. Default is UnicodeText. Required.
Exceptions
The following conditions may cause an exception:
text is an empty string (ArgumentException).
text is Nothing (ArgumentNullException).
Remarks
Possible formats are CommaSeparatedValue, Html, Rtf and UnicodeText.
The method requires AllClipboard.
Previous Clipboard formats are not preserved.
Security Note: |
---|
Because the Clipboard can be accessed by other users, do not use it to store sensitive information, such as passwords or confidential data. |
Tasks
The following table lists examples of tasks involving the My.Computer.Clipboard.SetText method.
To |
See |
---|---|
Write text to the Clipboard |
Example
This example writes the string This is a test string. to the Clipboard.
My.Computer.Clipboard.SetText("This is a test string.")
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
System.Windows.Forms.TextDataFormat
My.Computer.Clipboard.ContainsText Method
My.Computer.Clipboard.GetText Method