The Clipboard Object in VB6


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.


Visual Basic study materials:


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.

Download this sample: Copy-paste sample



The SetTex method

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

Example:
Clipboard.SetText Text1.Text



The Clear method

The Clear method clears the clipboard.

Example:
Clipboard.Clear



The GetTex method

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

Example:
Text2.Text = Clipboard.GetText



The SetData method

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

Example:
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.

Example:
Picture2.Picture = Clipboard.GetData


Download sample: Copy-paste sample