====== Working with clipboard ======
A problem with reading the clipboard is that we don't know what data type the clipboard contains of. To check this we could use My.Computer.Clipboard.Contains... for the data types we want to check, the return value will be a boolean value which will tell us if the clipboard contains the special data type or not. The data types that we can check for are:
My.Computer.Clipboard.ContainsAudio()
My.Computer.Clipboard.ContainsData()
My.Computer.Clipboard.ContainsFileDropList()
My.Computer.Clipboard.ContainsImage()
My.Computer.Clipboard.ContainsText()
Note that here again the ContainsData is used together with a parameter telling it which format we want to use, also note that there's nothing called ContainsDataObject. A simple example to check if the data is text:
If My.Computer.Clipboard.ContainsText() = True Then
Me.Text = My.Computer.Clipboard.GetText
End If
Quasi advanced sample
Select Case True
Case Windows.Forms.Clipboard.ContainsAudio
Case Windows.Forms.Clipboard.ContainsData("Format") 'Replace "Format" with the name of the custom format you wish to check.
Case Windows.Forms.Clipboard.ContainsFileDropList
Case Windows.Forms.Clipboard.ContainsImage
Me.BackgroundImage = My.Computer.Clipboard.GetImage
Case Windows.Forms.Clipboard.ContainsText
Me.Text = My.Computer.Clipboard.GetText
Case Else
End Select