In VB6 you can copy and paste images in the Device Independent Bitmaps (DIB) format, as in this code:
Clipboard.SetData Picture1.Picture, vbCFDIB
Set Picture2.Picture = Clipboard.GetData(vbCFDIB)
The above code is migrated to VB.NET correctly, except that it uses the Clipboard6 object defined in the language support library:
Clipboard6.SetData(Picture1.Picture, VBRUN.ClipBoardConstants.vbCFDIB)
Picture2.Picture = Clipboard6.GetData(VBRUN.ClipBoardConstants.vbCFDIB)
Our tests show, however, that the .NET Clipboard has problems working with the DIB format and that the GetData method returns a MemoryStream object instead of an Image object, which in turn causes an exception to be thrown when this object is assigned to the Picture property of the Picture1 control.
To reduce the odds of a runtime error in your applications, the Clipboard6.GetData method treats the vbCFDIB format as if the vbCFBitmap format were specified instead. This isn’t usually a problem, because applications that copy images to the Clipboard in the DIB format usually copy them also in the raw BMP format; therefore in virtually all cases the GetData method retrieves the right image.
Along the same lines, when you pass the vbCFDIB format to the Clipboard6.SetData method, then the image is stored both in DIB format and in raw BMP format, so that other applications can retrieve the image in DIB format, if they need to.
If you don’t want the Clipboard6 object to perform these automatic conversions for you and prefer to be in full control of the DIB vs. BMP format used when copying and pasting images, then you should edit the converted VB.NET and use the My.Computer.Clipboard object instead, as in the following code:
My.Computer.Clipboard.SetData(Picture1.Picture, DataFormats.Dib)
Picture2.Picture = My.Computer.Clipbard.GetData(DataFormats.Dib)