Results 1 to 9 of 9

Thread: [RESOLVED] How do I tell if the Clipboard is Clear? (No data in clipboard)

  1. #1

    Thread Starter
    Hyperactive Member stilekid007's Avatar
    Join Date
    Apr 2005
    Location
    DUDE! I'm your neighbor! HELLO!!!
    Posts
    388

    Resolved [RESOLVED] How do I tell if the Clipboard is Clear? (No data in clipboard)

    Hello there everyone!

    How do I tell if the Clipboard has any data stored in it?

    Thank you and have a great day!
    Stilekid007
    Quote Originally Posted by stilekid007
    I RATE ALL HELPFULL POSTS!

  2. #2
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: How do I tell if the Clipboard is Clear? (No data in clipboard)

    VB Code:
    1. If Len(Clipboard.GetText) = 0 Then
    2.     MsgBox "Clipboard cleared"
    3. Else
    4.     MsgBox Clipboard.GetText
    5. End If

    I think that will work good

  3. #3
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: How do I tell if the Clipboard is Clear? (No data in clipboard)

    Unless it's an object. You'd have to test both.

  4. #4
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: How do I tell if the Clipboard is Clear? (No data in clipboard)

    good point, would the same technique work?

  5. #5

    Thread Starter
    Hyperactive Member stilekid007's Avatar
    Join Date
    Apr 2005
    Location
    DUDE! I'm your neighbor! HELLO!!!
    Posts
    388

    Re: How do I tell if the Clipboard is Clear? (No data in clipboard)

    Hey,

    Thank you so much for your responses!

    How would I test to see if it is an object?

    Stilekid007
    Quote Originally Posted by stilekid007
    I RATE ALL HELPFULL POSTS!

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: How do I tell if the Clipboard is Clear? (No data in clipboard)

    Here are the Clipboard objects (it can support one of each at the same time)

    Constant Description
    vbCFLink Dynamic data exchange link.
    vbCFText Text. Examples earlier in this chapter all use this format.
    vbCFBitmap Bitmap.
    vbCFMetafile Metafile.
    vbCFDIB Device-independent bitmap.
    vbCFPalette Color palette.
    Here is how the menu_Paste does it:
    VB Code:
    1. Private Sub mnuPaste_Click ()
    2.    If TypeOf Screen.ActiveControl Is TextBox Then
    3.       Screen.ActiveControl.SelText = Clipboard.GetText()
    4.    ElseIf TypeOf Screen.ActiveControl Is ComboBox Then
    5.       Screen.ActiveControl.Text = Clipboard.GetText()
    6.    ElseIf TypeOf Screen.ActiveControl Is PictureBox _
    7.          Then
    8.       Screen.ActiveControl.Picture = _
    9.          Clipboard.GetData()
    10.    ElseIf TypeOf Screen.ActiveControl Is ListBox Then
    11.       Screen.ActiveControl.AddItem Clipboard.GetText()
    12.    Else
    13.       ' No action makes sense for the other controls.
    14.    End If
    15. End Sub

    I would think that you could test an object against Nothing to see if it's empty, but haven't tried it yet.

  7. #7

    Thread Starter
    Hyperactive Member stilekid007's Avatar
    Join Date
    Apr 2005
    Location
    DUDE! I'm your neighbor! HELLO!!!
    Posts
    388

    Re: How do I tell if the Clipboard is Clear? (No data in clipboard)

    I don't understand what this code does.

    I put it in a cmd button and nothing happens.

    Is this supposed to check to see if the clipboard has data?

    VB Code:
    1. Private Sub mnuPaste_Click ()
    2.    If TypeOf Screen.ActiveControl Is TextBox Then
    3.       Screen.ActiveControl.SelText = Clipboard.GetText()
    4.    ElseIf TypeOf Screen.ActiveControl Is ComboBox Then
    5.       Screen.ActiveControl.Text = Clipboard.GetText()
    6.    ElseIf TypeOf Screen.ActiveControl Is PictureBox _
    7.          Then
    8.       Screen.ActiveControl.Picture = _
    9.          Clipboard.GetData()
    10.    ElseIf TypeOf Screen.ActiveControl Is ListBox Then
    11.       Screen.ActiveControl.AddItem Clipboard.GetText()
    12.    Else
    13.       ' No action makes sense for the other controls.
    14.    End If
    15. End Sub

    Thank you!
    Stilekid007
    Quote Originally Posted by stilekid007
    I RATE ALL HELPFULL POSTS!

  8. #8
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: How do I tell if the Clipboard is Clear? (No data in clipboard)

    Here, this will tell you if anything is stored in the clipboard

    VB Code:
    1. Option Explicit
    2. Private Sub Form_Load()
    3. If GetClipData = True Then MsgBox "Clipboard Full!"
    4. End Sub
    5.  
    6. Private Function GetClipData() As Boolean
    7. Dim x As Variant
    8. x = Clipboard.GetData
    9.     If x <> 0 Or _
    10.         Len(Clipboard.GetText) <> 0 Then
    11.            GetClipData = True
    12.     End If
    13. End Function

  9. #9

    Thread Starter
    Hyperactive Member stilekid007's Avatar
    Join Date
    Apr 2005
    Location
    DUDE! I'm your neighbor! HELLO!!!
    Posts
    388

    Re: How do I tell if the Clipboard is Clear? (No data in clipboard)

    Ok, cool!

    Thank you to the both of you for your help and code!

    It works great!
    Stilekid007
    Quote Originally Posted by stilekid007
    I RATE ALL HELPFULL POSTS!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width