Clipboard.GetDataObject Method |
System.Windows.Forms.Clipboard
Clipboard.GetDataObject( )
An IDataObject object that represents the data currently on the clipboard
Retrieves data from the Clipboard
If the Clipboard contains no data, the GetDataObject method returns Nothing .
Once you have an IDataObject object, you can use the members of the IDataObject class to get information about the Clipboard data, as shown in the following example. The relevant IDataObject members for Clipboard manipulation in VB are GetData, GetDataPresent, and GetFormats.
The following example extracts the text that is currently on the Clipboard:
' Declare IDataObject variable and get clipboard IDataObject Dim di As IDataObject = Clipboard.GetDataObject Dim obj As Object ' Fire GetData method of IDataObject object to get clipboard data obj = di.GetData(DataFormats.Text, False) ' Show the text, if any If obj Is Nothing Then MsgBox("No text on clipboard.") Else MsgBox(CStr(obj)) End If
While the .NET Base Class Library uses the GetDataObject method to retrieve all data from the Clipboard, the Clipboard object in VB 6 included the GetFormat, GetData, and GetText methods to retrieve Clipboard data.
Clipboard Class, Clipboard.SetDataObject Method, IDataObject Interface