|
-
Jul 18th, 2005, 08:06 PM
#1
Thread Starter
Hyperactive Member
[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
 Originally Posted by stilekid007
-
Jul 18th, 2005, 08:09 PM
#2
Re: How do I tell if the Clipboard is Clear? (No data in clipboard)
VB Code:
If Len(Clipboard.GetText) = 0 Then
MsgBox "Clipboard cleared"
Else
MsgBox Clipboard.GetText
End If
I think that will work good
-
Jul 18th, 2005, 08:11 PM
#3
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.
-
Jul 18th, 2005, 08:14 PM
#4
Re: How do I tell if the Clipboard is Clear? (No data in clipboard)
good point, would the same technique work?
-
Jul 18th, 2005, 08:29 PM
#5
Thread Starter
Hyperactive Member
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
 Originally Posted by stilekid007
-
Jul 18th, 2005, 08:37 PM
#6
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:
Private Sub mnuPaste_Click ()
If TypeOf Screen.ActiveControl Is TextBox Then
Screen.ActiveControl.SelText = Clipboard.GetText()
ElseIf TypeOf Screen.ActiveControl Is ComboBox Then
Screen.ActiveControl.Text = Clipboard.GetText()
ElseIf TypeOf Screen.ActiveControl Is PictureBox _
Then
Screen.ActiveControl.Picture = _
Clipboard.GetData()
ElseIf TypeOf Screen.ActiveControl Is ListBox Then
Screen.ActiveControl.AddItem Clipboard.GetText()
Else
' No action makes sense for the other controls.
End If
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.
-
Jul 18th, 2005, 08:49 PM
#7
Thread Starter
Hyperactive Member
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:
Private Sub mnuPaste_Click ()
If TypeOf Screen.ActiveControl Is TextBox Then
Screen.ActiveControl.SelText = Clipboard.GetText()
ElseIf TypeOf Screen.ActiveControl Is ComboBox Then
Screen.ActiveControl.Text = Clipboard.GetText()
ElseIf TypeOf Screen.ActiveControl Is PictureBox _
Then
Screen.ActiveControl.Picture = _
Clipboard.GetData()
ElseIf TypeOf Screen.ActiveControl Is ListBox Then
Screen.ActiveControl.AddItem Clipboard.GetText()
Else
' No action makes sense for the other controls.
End If
End Sub
Thank you!
Stilekid007
 Originally Posted by stilekid007
-
Jul 18th, 2005, 09:58 PM
#8
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:
Option Explicit
Private Sub Form_Load()
If GetClipData = True Then MsgBox "Clipboard Full!"
End Sub
Private Function GetClipData() As Boolean
Dim x As Variant
x = Clipboard.GetData
If x <> 0 Or _
Len(Clipboard.GetText) <> 0 Then
GetClipData = True
End If
End Function
-
Jul 18th, 2005, 10:12 PM
#9
Thread Starter
Hyperactive Member
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
 Originally Posted by stilekid007
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|