GetFormat Method

See Also734K0BV              ExampleL5M26H>Low

Returns an integer indicating whether there is an item in the operating environment Clipboard that matches a specified format.

Syntax

Clipboard.GetFormat (format)

Remarks

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

 

Symbolic constant   Value      Clipboard format

 

CF_LINK                   &HBF00   DDE conversation information

CF_TEXT                  1             Text

CF_BITMAP              2             Bitmap (.BMP files)

CF_METAFILE          3             Metafile (.WMF files)

CF_DIB                     8             Device-independent bitmap

CF_PALETTE            9             Color palette

 

The GetFormat method returns True if there is an item on the Clipboard that matches the specified format.  Otherwise, it returns False.

For CF_DIB and CF_BITMAP formats, any palette on the Clipboard will be used when the picture is displayed.

 

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

GetData MethodZIOQ42

GetText MethodZJ4U8E


GetFormat Method Example

The example uses the GetFormat method to determine the format of data on the Clipboard.  To try this example, paste the code into the Declarations section of a form.  Then press F5 and click the form.

 

Sub Form_Click ()

   ' Define bitmap formats.

   Const CF_TEXT = 1, CF_BITMAP = 2, CF_DIB = 8, CF_PALETTE = 9

   Dim ClpFmt, Msg                       ' Declare variables

   On Error Resume Next                  ' Set up error handling.

   If Clipboard.GetFormat(CF_TEXT) Then ClpFmt = ClpFmt + 1

   If Clipboard.GetFormat(CF_BITMAP) Then ClpFmt = ClpFmt + 2

   If Clipboard.GetFormat(CF_DIB) Then ClpFmt = ClpFmt + 4

   Select Case ClpFmt

      Case 1

         Msg = "The Clipboard contains only text."

      Case 2, 4, 6

         Msg = "The Clipboard contains only a bitmap."

      Case 3, 5, 7

         Msg = "The Clipboard contains text and a bitmap."

      Case Else

         Msg = "There is nothing on the Clipboard."

   End Select

   MsgBox Msg                            ' Display message.

End Sub