Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

How to: Determine What Type of File is Stored on the Clipboard in Visual Basic

The Clipboard can be used to store data, such as text and images. Because the Clipboard is available across processes, it can be used to transfer data between them. The My.Computer.Clipboard object allows you to easily access the Clipboard and to read and write to it.

Data on the Clipboard may take a number of different forms, such as text, an audio file, or an image. In order to determine what sort of file is on the Clipboard, you can use methods such as ContainsAudio, ContainsFileDropList, ContainsImage, and ContainsText. The ContainsData method can be used if you have a custom format that you want to check.

To determine whether the Clipboard holds an image

  • Use the ContainsImage function to determine whether the data contained on the Clipboard is an image. The following code checks to see whether the data is an image and reports accordingly.

    If My.Computer.Clipboard.ContainsImage() Then
        MsgBox("Clipboard contains an image.")
        MsgBox("Clipboard does not contain an image.")
    End If

Community Additions

© 2015 Microsoft