Search Tools Links Login

VB6 Tutorial 68: Using the Clipboard

Posted: 2018-06-10
By: vb6boy
Viewed: 6,200

Filed Under:

Visual Basic 6

No attachments for this post

Clipboard object is a simple object in Visual Basic 6 that stores data. You can retrieve the data from the clipboard using appropriate methods of the clipboard object.

In the Windows operating system, when you copy some data, the data is automatically copied or stored in the clipboard object. You can place data in the clipboard object and retrieve the data from clipboard.

You can easily copy and paste data among applications - from one application to another using the clipboard object. The clipboard object has no properties. It has a few methods that help you work upon the data.

The SetText method

The SetText method puts text in the clipboard. In other words, you can place text in the clipboard object using this method.


Clipboard.SetText Text1.Text

The Clear method

The Clear method clears the clipboard.



The GetText method

The GetTex method lets you retrieve the text which is in clipboard.


Text2.Text = Clipboard.GetText

The SetData method

The SetData method places data e.g an image in clipboard.


Clipboard.SetData Picture1.Picture
' or
Clipboard.SetData LoadPicture("d:\mypic.bmp")

The GetData method

The GetData method retrieves data, for example an image, from the clipboard object.


Picture2.Picture = Clipboard.GetData

Comments on this post

AnonymousCoward posted this comment on 2019-09-14:

The methods are "GetText" and "SetText"

dwirch posted this comment on 2019-09-15:

Thank you for catching the typo.  It's been corrected.

AnonymousCoward posted this comment on 2020-06-21:

I have the following lines in my VB6 program:

   frmTimer.txtPassword.Text = "Whatever"
   ClipBoard.SetText (frmTimer.txtPassword.Text)

When I try to paste this text, it appears not to be in the Clipboard. This problem just recently manifested itself. Can you help me?

dwirch posted this comment on 2020-06-22:

If there is existing data in the clipboard, you need to clear it first, with this command:


You must be logged in to make a comment.