by Alok Rai (3 Submissions)
Category: Windows System Services
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 28th May 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Shows how to grab and set clipboard data.
API Declarations
' first put one richtextbox and picture box in the form and also put threee
'command button at the bottom and named them display clipboard data,clearclipboarddata,savedata in clipboard and see the effect
RichTextBox1.Text = ""
RichTextBox1.TextRTF = ""
If Clipboard.GetFormat(vbCFText) Then
MsgBox "The Clipboard contains only text.", vbSystemModal, "Clipboard"
RichTextBox1.Visible = True
Image1.Visible = False
RichTextBox1.Text = Clipboard.GetText()
ElseIf Clipboard.GetFormat(vbCFBitmap) Then
RichTextBox1.Visible = False
Image1.Visible = True
MsgBox "The Clipboard contains the Bitmap.", vbSystemModal, "Clipboard"
Picture = Clipboard.GetData()
Image1.Picture = Picture
ElseIf Clipboard.GetFormat(vbCFDIB) Then
Image1.Visible = False
RichTextBox1.Visible = True
MsgBox "The Clipboard contains only rich text.", vbSystemModal, "Clipboard"
RichTextBox1.TextRTF = Clipboard.GetText()
ElseIf Clipboard.GetFormat(vbCFRTF) Then
Image1.Visible = False
RichTextBox1.Visible = False
MsgBox "There is nothing on the Clipboard.", vbSystemModal, "Clipboard"
End If
End Sub
Private Sub Command2_Click()
Clipboard.Clear
End Sub
Private Sub Command3_Click()
If RichTextBox1.Visible = True Then
Clipboard.SetText RichTextBox1.Text
Else
Clipboard.SetData Image1.Picture
End If
End Sub
Private Sub Form_Load()
Image1.Visible = False
RichTextBox1.Visible = False
End Sub