GetData Method

See Also121FAYJ              Example16HPOW0>Low

Returns a picture from the operating environment Clipboard object.

Syntax

Clipboard.GetData ([format])

Remarks

The argument format specifies one of the following Clipboard formats recognized by Visual Basic:

 

Symbolic constant    Value      Clipboard format

 

CF_BITMAP                  2          Bitmap (.BMP files)

CF_METAFILE              3          Metafile (.WMF files)

CF_DIB                         8          Device-independent bitmap

CF_PALETTE                9          Color palette

 

If format is 0 or omitted, GetData automatically uses the appropriate format.

If there is no picture on the Clipboard that matches the expected format, a null picture is returned.  If only a color palette is present on the Clipboard, a minimum size (1 x 1) device-independent bitmap is created.

 

Note   Symbolic constants for Clipboard format definitions can be found in the Visual Basic file CONSTANT.TXT.  When placed in any module in a project, the symbolic names can be used in all your form and code modules.

 


See Also

Clipboard Object6WM59T

GetFormat MethodNGJXI2

GetText MethodZJ4U8E

SetData Method3EBYPZ


GetData Method Example

The example uses the GetData method to copy a bitmap from the Clipboard to a form.  To try this example, paste the code into the Declarations section of a form.  Then press F5 and click the form.

 

Sub Form_Click ()

   Const CF_BITMAP = 2                         ' Define bitmap format.

   Dim Msg                                     ' Declare variable.

   On Error Resume Next                        ' Set up error handling.

   Msg = "Choose OK to load a bitmap onto the Clipboard."

   MsgBox Msg                                  ' Display message.

   Clipboard.Clear                             ' Clear Clipboard.

   Clipboard.SetData LoadPicture("PAPER.BMP")  ' Get bitmap.

   If Err Then

      Msg = "Could not find the .BMP file."

      MsgBox Msg                               ' Display error message.

      Exit Sub

   End If

   Msg = "A bitmap is now on the Clipboard. Choose OK to copy "

   Msg = Msg & "the bitmap from the Clipboard to the form "

   MsgBox Msg                                  ' Display message.

   Picture = Clipboard.GetData()               ' Copy from Clipboard.

   Msg = "Choose OK to clear the picture box."

   MsgBox Msg                                  ' Display message.

   Picture = LoadPicture()                     ' Clear picture box.

End Sub