My.Computer.Clipboard: Clear, ContainText, SetDataObject and GetText : Clipboard « Development « VB.Net Tutorial






Option Strict On

Imports System.Windows.Forms

Public Module Clipbrd
   Public Sub Main()
      Dim stringToWrite As String = "This data belongs on the Clipboard."
      Dim stringToRead As String

      My.Computer.Clipboard.Clear()

      Dim data As DataObject = New DataObject(DataFormats.Text, stringToWrite)
      My.Computer.Clipboard.SetDataObject(data)

      If My.Computer.Clipboard.ContainsText() Then
         stringToRead = My.Computer.Clipboard.GetText()
         Console.WriteLine("The text on the Clipboard: {0}", stringToRead)
      Else
         Console.WriteLine("There is no text on the Clipboard.")
      End If
   End Sub
End Module
The text on the Clipboard: This data belongs on the Clipboard.








7.27.Clipboard
7.27.1.My.Computer.Clipboard: Clear, ContainText, SetDataObject and GetText